c.php <?php $db_name="test";//数据库 $server_name="localhost";//服务器 $conn=mysqli_connect($server_name,"root","",$db_name);//链接数据库 if(!$conn)//连不上数据库 { die("连接错误" . mysqli_connect_error()); exit; } $curDb=mysqli_select_db($conn,$db_name);//选择数据库 if(!$curDb)//数据库不存在 { die("不存在" . $db_name); exit; } $user_name=$_GET['user_name'];//获取用户名和密码 $password=$_GET['password']; $denglu="select user_name,password from users where user_name='" . $user_name ; echo $denglu ; if($user_name) { $result=mysqli_query($conn,$denglu);//执行sql语句查询用户名 $rows=mysqli_num_rows($result);//遍历查询结果 if($rows) { $denglu2="select user_name,password from users where user_name='" . $user_name . "' and password = '" . $password . "'"; $result2=mysqli_query($conn,$denglu2);//执行sql语句查询用户名 $rows2=mysqli_num_rows($result2);//遍历查询结果 if($rows) { echo "登陆成功!";} else { echo "密码错误!";} } else { echo "用户不存在"; exit; } } else { echo "用户名或密码错误!"; } ?>
c.html <!DOCTYPE html> <html> <head> <title>login</title> </head> <body> <form action="c.php" method="get"> <h3>User name:</h3> <input type="text" name="user_name"/> </br></br> <h3>password:</h3> <input type="text" name="password"> </br></br> <input type="submit"> </form> </body> </html>
打赏我,让我更有动力~
© 2016 - 2024 掌控者 All Rights Reserved.
Track-方丈
发表于 2018-6-3
通过
评论列表
加载数据中...