Maison > Article > développement back-end > 这两种登陆验证方法错哪了
这两种登陆验证方法哪里错了
第一种:
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --><?php $id=$_POST['id']; $password=$_POST['password']; $conn=mysql_connect("localhost","root","root"); if (!$conn){ die("连接失败:".mysql_errno()); } mysql_select_db("emp",$conn) or die(mysql_errno()); mysql_query("set names utf8")or die(mysql_errno()); $sql = "select count(id) from admin where id='".$id."' and password='".md5($password)."'"; $res = mysql_query($sql,$conn); $num = mysql_num_rows($res); if($num){ header("location:empManage.php"); exit(); }else{ header("location:login.php?errno=1"); exit(); } mysql_free_result($res); mysql_close($conn); ?>
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --><?php $id=$_POST['id']; $password=$_POST['password']; $conn=mysql_connect("localhost","root","root"); if (!$conn){ die("连接失败:".mysql_errno()); } mysql_select_db("emp",$conn) or die(mysql_errno()); mysql_query("set names utf8")or die(mysql_errno()); $sql="select password from admin where id=$id"; $res=mysql_query($sql,$conn); if ($row=mysql_fetch_assoc($res)){ if ($row['password']==md5($password)){ header("location:empManage.php"); } } header("location:login.php?errno=1"); mysql_free_result($res); mysql_close($conn); ?>