PHP ヘッダーの問題
次のコードが表示され続けます 警告: ヘッダー情報は変更できません - ヘッダーは既に送信されています (出力は D:AppServwwwadmin_check.php:1 で開始されました) in D:AppServwwwadmin_check.php の 10 行目
< ; ?php
require_once 'user_service.class.php';
$admin_id=$_POST['admin_id'];
$admin_password=$_POST['admin_password'];
$userService=new userservice();
if($name=$userService->checkUser($admin_id, $admin_password)){
header("Location: manage.php?name= $ admin_id");
exit;
}else{
header("Location:login.php?error=1");
exit;
}
?>このコードのフロントエンドには問題はありませんが、ヘッダーの実行時がすべて問題です
This is user_service.class.php
require_once 'sqlhelper.class.php';
require_once 'user.class.php';
class userservice{
// ユーザー名に基づいてアカウント情報を取得するメソッドを提供します
public function getUserByName($name ) {
$sql="select * from user where name='".$name."'";
$sqlHelper= new sqlhelper();
$ arr=$sqlHelper->dql2($sql);
$sqlHelper->close_conn();
return $arr;//
}
//提供されたユーザーが正当であるかどうかを検証するメソッド
public function checkUser($name,$password){
$sql="select password ,name from user where name='".$ name."'";
//sqlhelper オブジェクトを作成します
$sqlHelper=new sqlhelper();
$res=$sqlHelper->dql($sql );
if($row =mysql_fetch_assoc($res)){
//パスワードを比較
if($password==$row['password']){
return $row[' name'];
}
}
mysql_free_result($res);
$sqlHelper->close_conn();
return "";
}
public function gengGPassword($ name,$newpassword){
$sql="ユーザー設定パスワードの更新='".$newpassword."' where name='".$name."'";
$sqlHelper =new sqlhelper();
$res=$sqlHelper->dql($sql);
// mysql_free_result($res);
$sqlHelper->close_conn( );
}
}
?>
sqlhelper.class.php コード
//ツールクラス
class sqlhelper{
public $host="localhost";
public $user="root";
public $password="123456";
public $db="bishe";
public $conn;
public function sqlhelper(){
$this->conn=mysql_connect("localhost","root","123456") または die ("123". mysql_errno () );
if(!$this->conn){
die("接続に失敗しました".mysql_errno());
}
mysql_query("set names utf8 ");
mysql_select_db( $this->db,$this->conn);
}
public function dql($sql){
$res=mysql_query($sql, $this->conn)or die(mysql_errno());
return $res;
}
public function dql2($sql){
$res=mysql_query ($sql,$this->conn)or die("エラー! ".mysql_errno());
$arr=mysql_fetch_array($res,$this->conn);
return $arr;
/* echo $arr[0],$arr ['1'];
$result = mysql_query("SELECT * from user where name='xiaowang'");
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
printf ("ID: %s 名前: %s", $row[0], $row[1]);
}
mysql_free_result($result);
return $row; */
}
//パブリック関数 dql2($sql){
// $res=mysql_query($sql,$this->conn)or die(mysql_errno());
//return $res;
//}
//削除?
public function dml($sql){
$b=mysql_query($sql,$this->conn) );
if (!$b) {
return 0;//失敗
;
}else {
if (mysql_affected_rows($this->conn)>0){
return 1;//実行がOKであることを示します
}else {
return 2;//行が影響を受けないことを示します
}
}
}
パブリック関数 close_conn(){

aphpDependencyInjectionContaineriSATOULTAINATINAGECLASSDEPTINCIES、強化測定性、テスト可能性、および維持可能性。

SELECT DEPENTENCINGINOFCENT(DI)大規模なアプリケーションの場合、ServicElocatorは小さなプロジェクトまたはプロトタイプに適しています。 1)DIは、コンストラクターインジェクションを通じてコードのテスト可能性とモジュール性を改善します。 2)ServiceLocatorは、センター登録を通じてサービスを取得します。これは便利ですが、コードカップリングの増加につながる可能性があります。

phpapplicationscanbeoptimizedforspeedandEfficiencyby:1)enabingopcacheinphp.ini、2)PreparedStatementswithpordatabasequeriesを使用して、3)LoopswithArray_filterandarray_mapfordataprocessing、4)の構成ngincasaSearverseproxy、5)

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl

tomakephpapplicationsfaster、followthesesteps:1)useopcodecachinglikeopcacheTostoredscriptbytecode.2)最小化abasequeriesecachingingindexing.3)leveragephp7機能forbettercodeefficiency.4)

依存性注入(DI)は、明示的に推移的な依存関係によりPHPコードのテスト可能性を大幅に改善します。 1)DI分離クラスと特定の実装により、テストとメンテナンスが柔軟になります。 2)3つのタイプのうち、コンストラクターは、状態を一貫性に保つために明示的な式依存性を注入します。 3)DIコンテナを使用して複雑な依存関係を管理し、コードの品質と開発効率を向上させます。

DatabaseQueryoptimizationInpholvesseveralstrategESTOEnhancePerformance.1)selectonlynlynlyndorycolumnStoredatedataTransfer.2)useindexingtospeedupdataretrieval.3)revenmecrycachingtostoreres sultsoffrequent queries.4)


ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

Video Face Swap
完全無料の AI 顔交換ツールを使用して、あらゆるビデオの顔を簡単に交換できます。

人気の記事

ホットツール

EditPlus 中国語クラック版
サイズが小さく、構文の強調表示、コード プロンプト機能はサポートされていません

PhpStorm Mac バージョン
最新(2018.2.1)のプロフェッショナル向けPHP統合開発ツール

SublimeText3 Linux 新バージョン
SublimeText3 Linux 最新バージョン

WebStorm Mac版
便利なJavaScript開発ツール

ZendStudio 13.5.1 Mac
強力な PHP 統合開発環境
