<!DOCTYPE html>
<html>
<head>
<title>请输入账号密码</title>
</head>
<body>
<form action="1.php" method="get">
<p>帐号:<input type="text" name="username"/></p>
<p>密码:<input type="text" name="password"></p>
<input type="submit" value="登录">
</form>
</body>
</html>
1.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['username'];//获取用户名和密码
$password=$_GET['password'];
$login="select user_name,password from users where user_name='".$user_name."'" ;
echo $login ;
if($user_name)
{
$result=mysqli_query($conn,$login);//查询用户名
$rows=mysqli_num_rows($result);//结果遍历
if($rows)
{
$mima="select user_name,password from users where user_name='".$user_name."'and password='".$password."'";
$result2=mysqli_query($conn,$mima);//查询用户名
$rows2=mysqli_num_rows($result2);//结果遍历
if($rows)
{ echo "登陆成功!";}
else
{ echo "用户名或密码错误!";}
}
else
{
echo "用户名或密码错误!";
exit;
}
}
else
{
echo "用户名或密码错误!";
}
?>
打赏我,让我更有动力~
© 2016 - 2024 掌控者 All Rights Reserved.
Track-方丈
发表于 2018-6-13
通过
评论列表
加载数据中...