<!doctype html>
<html>
<meta charest="utf-8" />
<head>有2个或多个字段的用户登录表单,点击按钮后提交到后端PHP,判断是否登陆成功</head>
<body>
<p>管理员登录</p>
<form action="a.php" method="post">
<input type="txt" name="username" value=""><br>
<input type="txt" name="password" value=""><br>
<input type="submit" name ="submit" value="提交">
</form>
</body>
</html>
文件a.php
<?php
header('content-type:a/html;charset=utf-8');
$username=$_POST['username'];
$password=$_POST['password'];
$conn=mysqli_connect("localhost","root","root","db_name");
if (!$con)
{
die('Could not connect:'. mysql_error());
}
$result = mysqli_query($conn,"SELECT * FROM user WHERE username='".mysql_real_escape_string($username)."'AND password='".mysql_real_escape_string($password)."'");
$row=mysql_fetch_row($result);
if($row>0)
{
echo"登陆成功";
}
else
{
echo"用户名或密码错误";
}
mysqli_close($conn);
?>
打赏我,让我更有动力~
© 2016 - 2024 掌控者 All Rights Reserved.
Track-方丈
发表于 2018-7-20
通过,金币奖励已发放、
评论列表
加载数据中...