我試圖登錄使用此代碼:成功登錄後PHP日誌中的錯誤未定義指數
session_start();
require "connect.php";
$username = $_POST['username'];
$password = $_POST['password'];
if($username&&$password)
{
$query = mysql_query("SELECT * FROM users WHERE username='$username'");
$numrow = mysql_num_rows($query);
if($numrow!=0)
{
while($row = mysql_fetch_assoc($query))
{
$db_username = $row['username'];
$db_password = $row['password'];
}
if($username==$db_username&&$password==$db_password)
{
//echo 1;
header("Location: members.php");
$_SESSION['username']=$db_username;
}
else echo 0;
}
else die("That user doesn't exist");
}
else die("Please enter a username and password");
在它應該帶我去members.php:
session_start();
if($_SESSION['username']) <------ this is line 5
{
echo "20730312";
echo " You are logged in as: ".$_SESSION['username'];
echo "<p><a href='logout.php'>Click here to logout</a>";
}
,但是當我請求members.php在我的應用它給了我:
Notice: Undefined index: username in E:\Program Files\xampp\htdocs\adddrop\members.php on line 5
請注意,我採用了android的WebView成功LO後要求members.php克在,是這樣嗎?我究竟做錯了什麼 ?
感謝您的回答,但我試過你的解決方案,它仍然給我同樣的通知。和關於SQL注入我不擔心安全問題,但無論如何感謝。 – Jawad