<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>登录页面</title>
</head>
<body>
<p>管理员登录</p>
<form name="denglu" method="POST" action="2.php">
用户名:<input type="text" name="username" value="" /><br/>
密码:<input type="password" name="password" value="" /><br/>
<input type="submit" name="submit" value="提交" />
</form>
</body>
</html>
<?php
//连接数据库
$conn=mysql_connect("localhost","root","root","db_test")or defead("连接数据库失败");
//选择数据库
mysql_select_db($conn,"db_test");
//获取表单数据
$account=$_POST['account'];
$password=$_POST['password'];
//$password=123456($password);
$sql="select * from admin where account='{$account}'";
//执行sql语句
$result=mysql_query($sql);
//获取记录数
$num=mysql_num_rows($result);
if($num){
$row=mysql_fetch_array($result);
if($password===$row['password']){
echo "登陆成功";}
else{
echo "密码错误";
echo "<a href='http://localhost'>返回登陆页面</a>";
}}
?>
打赏我,让我更有动力~
© 2016 - 2024 掌控者 All Rights Reserved.
Track-方丈
发表于 2018-7-1
通过。
评论列表
加载数据中...