へえ、私の現在のディレクトリ構造は
- 管理者 (index.php、country.php)
- クラス(connection.php、login.php、country.php)
- header.php
- フッター.php
- index.php
- インクルード (header.php,footer.php)
私の問題は、/admin/ country.php にいて、フォーム ポスト メソッドを使用して国を追加し、 /classes/ country.phpに設定されたアクションをWeb サーバーに追加するときに、ヘッダー ステートメント " Header("Location: ../Admin/country. php") " は問題なく動作していますが、ルート ディレクトリのインデックス ページにいて、フォーム アクション"classes/login.php"でログインしようとすると、ログインに成功すると、header("Location: ../Admin/index. php")リダイレクトすることはありませんが、ローカル サーバーではすべて正常に動作します。ここで何が問題なのかわかりません。助けていただければ幸いです。このフォーラムや他のフォーラムを検索し、彼らが言ったテクニックを使用しようとしましたが、何もしませんでした。は働いている
私のインデックスページindex.php
私の管理セクションAdmin/Country.php
私のlogin.phpスクリプトは以下です
<?php
ob_start();
include_once("classes/connection.php");
?>
<?php
class login
{
public static function validateLogin($userName,$password)
{
if(isset($userName) && isset($password))
{
$connection = dbconnection::getConnection();
$query = "Select * from tbllogin Where loginID ='" . $userName .
"' and password = '" . $password . "'";
$result = mysql_query($query);
$rowsAffected = mysql_affected_rows();
if($rowsAffected==0)
{
//header("Location: ../index.php/");
//exit();
return false;
}
else
{
while($row = mysql_fetch_array($result))
{
//working
$role = $row["role"];
if($role == "Admin")
{
//header('Location: ../Admin/index.php');
//exit();
return true;
}
else
{
//echo "hello";
//header("Location: ../index.php/");
//exit();
return false;
}
//return $result;
//header("Location: ../index.php");
}
}
}
else
{
//header("Location: ../index.php/");
return false;
}
}
}
?>
<?php
if(isset($_POST["btnSumbit"]))
{
$isValid = login::validateLogin($_POST["userID"],$_POST["password"]);
if(isset($isValid))
{
if($isValid ==true)
{
$host = $_SERVER['HTTP_HOST'];
$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
$extra = 'Admin/index.php';
header("Location: http://$host$uri/$extra");
exit();
}
}
}
ob_end_flush();
?>