MySQL登录错误

时间:2015-04-14 20:19:25

标签: php mysql

我有这个错误,说

  

注意:未定义的索引:第33行的C:\ xampp \ htdocs \ TI \ TrackIt!\ System \ LOG.php中的uname   注意:未定义的索引:第34行的C:\ xampp \ htdocs \ TI \ TrackIt!\ System \ LOG.php中的pword

现在我的日志页面发生了什么,它接受任何用户名或用户名。我已经搜索了所提出的问题,而且没有什么可以帮助我。这是我的代码:

<form class="form-signin" role="form" action='CUSTOMER.php' method="POST">
<input type="text" class="form-control" name="uname" id="uname" placeholder="Username" required autofocus>
<input type="password" class="form-control" name="pword" id="pword" placeholder="Password" required>
<button class="btn btn-lg btn-primary btn-block" type="submit">Login</button>
</form>

这是PHP:

$myusername = $_POST['uname']; 
$mypassword = $_POST['pword'];
$DPassword = md5($mypassword); 

$sql = "SELECT uname, pword
  FROM Admin
  WHERE uname = '".$myusername."'
        AND Pword ='".$DPassword."'
         ";

$result=mysql_query($sql) OR die('error: '.mysql_error());
$row = mysql_fetch_array($result);
$count=mysql_num_rows($result);
if($count == 1){
  session_regenerate_id(true);
  $session_username = $myusername;
  $session_name = $row["name"];
  $_SESSION['uname'] = $session_username;
  $_SESSION['name'] = $session_name;
}
elseif(strlen($myusername) >= 2 && strlen($mypassword)>= 2)  
{
  echo "<script> alert('WRONG USERNAME OR PASSWORD'); </script>";
}
ob_end_flush();

0 个答案:

没有答案