doue2666 2019-03-28 07:48
浏览 20

php登录表单需要什么

I'm having problems with my log in php file. I completed my sign up form, which takes data and saves it in a database. I now want to be able to log in with the data from the db. This is my first log in form and I'm not sure if I have all the things needed to make it run or if there's just an error. A list of what is needed to make this log in form will help, Thank you. I would also like to mention that I have more data in the DB other than email/password.

<?php
$db  = mysql_connect("127.0.0.1:3307", "root", "", "test");


  if(!$db){die('could not connect:'.mysql_error());}

    echo'connected successfully';


 if (isset($_POST['submit'])) {

 $username = $_POST['Email'];
 $password = $_POST['Password'];

  $username = mysql_real_escape_string($Email);
  $password = mysql_real_escape_string($Password);

  $sql = "SELECT * FROM people WHERE Email ='$Email' AND 
   Password='$Password'";
 mysql_select_db('test');
  $result = mysql_query($sql);
 $count = mysql_num_rows($result);

 if($count == 1) {
 echo "<script> alert('You Have Successfully Logged In')</script>";

exit();
} else {
 echo "<script> alert('Invalid Username and/or Password')</script>";
 }
 }

  mysql_close($db);
?>
  • 写回答

1条回答 默认 最新

  • douniewei6346 2019-03-28 10:39
    关注

    You parse the POSTed EMAIL to your $username variable, but in your SELECT statement, you use a $Email variable. Perhaps this should have been your $Username variable instead, as this seems to hold your emailadress.

    So your problem is in mixing of email and username. Correct this and your script should work.

    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大