首页 > 代码库 > php登录验证及代码实现 含数据库设计 亲测有效
php登录验证及代码实现 含数据库设计 亲测有效
深夜调代码 试过无数种方法终于见了成效
login.php内容如下
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>管理员后台登录 </title> <!-- CSS --> <!-- Reset Stylesheet --> <link rel="stylesheet" href=http://www.mamicode.com/"resources/css/reset.css" type="text/css" media="screen" />>login_1.php内容如下
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <?php error_reporting(0); if(!isset($_POST['submit'])){ exit('非法访问!'); } $name=$_POST['loginName']; $password=$_POST['loginPwd']; include('connect.php'); if($name && $password){ echo "come in"; $sql="select * from admin where adName='$name' and adPwd='$password' "; $res=mysql_query($sql); echo "$res"; echo "$name"; $test=mysql_fetch_array($res); if($test && strcmp($name,'admin')==0){ header("location:index.php"); echo "finally"; exit; }else{ echo "fail to login"; exit; } mysql_free_result($res); mysql_close($conn); } ?>connect.php内容如下
<?php $conn=mysql_connect('localhost','root','') or die("连接失败".mysql_error()); mysql_select_db('door',$conn) or die("选择数据库失败".mysql_error()); mysql_query("set names gb2312"); ?>
数据库设计 如下
php登录验证及代码实现 含数据库设计 亲测有效
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。