日期:2014-05-17 浏览次数:20523 次
<?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); ?>
<?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); ?>