0
我收到此錯誤未定義指數:上登錄(PHP)
Notice: Undefined index: username in C:\xampp\htdocs\login.php on line 24
Notice: Undefined index: password in C:\xampp\htdocs\login.php on line 25
這個代碼
<?php
session_start();
$username = $_POST['username'];
$password = $_POST['password'];
if ($username&&$password)
{
$connect = mysql_connect("localhost","root","") or die ("couldn't connect");
mysql_select_db("test") or die ("couldn't find DB");
$query = mysql_query("select * FROM users WHERE username='$username'");
$numrows = mysql_num_rows($query);
if($numrows!=0)
{
//login goahead
while ($row = mysql_fetch_assoc($query))
{
$dbusername = $row['username'];
$dbpassword = $row['password'];
if($username==$dbusername&&$password==$dbpassword)
{
echo "You're in! <a href='member.php'>click here to continue</a>";
$_SESSION['username']=$username;
}
else
echo"Incorrect Password";
}
}
else
die("That user does not exist!");
}
else
die("please enter a username and password");
?>
我已經試過周圍改變其中的if語句來檢查數據庫的用戶名和傳遞是並試圖重新定義電話,但它不會工作。任何幫助都會很棒。
哈哈omg謝謝你指出了..我忘了封帽。把我帶回高中時代的人。萬分感謝 – user3204744