【发布时间】:2014-04-21 03:00:32
【问题描述】:
我一直在尝试测试登录 php,但在输入用户名和密码后,我收到此错误(注意:未定义索引:第 12 行 /web/stud/u1177827/store_admin/admin_login.php 中的用户名注意:未定义索引:第13行/web/stud/u1177827/store_admin/admin_login.php中的密码连接失败。该信息不正确,重试单击此处) 这是代码:
<?php
session_start();
if(isset($_SESSION["staff"])){
header("location:index.php");
exit();
}
?>
<?php
// Prase the log in form if the user has filled it out and pressed "Log in"
if(isset($_POST["username"])&& isset($_POST["password"])){
$username=preg_replace('#[^A-Za-z0-0]#i',"",$_SESSION["username"]);//filter everything but numbers and letters
$password=preg_replace('#[^A_Za-z0-9]#i',"",$_SESSION["password"]);//filter everything but numbers and letters
//Connect to the MySQL database
include "../storescripts/connectToMySQL.php";
$sql=mysql_query("SELECT*FROM B4UStaff WHERE fname='$username' AND lname='$password'LIMT 1");//query the person
//..... MAKE SURE PERSON EXISTS IN DATABASE....
$existCount=mysql_num_rows($sql);//count the row nums
if($existCount==1){//evaluate the count
while($row=mysql_fetch_array($sql)){
$staffNo=$row["staffNo"];
}
$_SESSION["staffNo"]=$staffNo;
$_SESSION["username"]=$username;
$_SESSION["password"]=$password;
header("location:index.php");
exit();
} else{
echo 'That information is incorrect, try again <a href="index.php">Click Here</a>';
exit();
}
}
?>
有人知道怎么解决吗?
【问题讨论】: