<!doctype html>
<html>
<head>
<meta charset = "utf-8"/>
<title>登录测试</title>
</head>
<body>
<form action="practice.php" method="POST">
账号:<input type = "text" name='u'><br/>
密码:<input type ="password" name='p'><br/>
<input type = "submit" value="提交">
</form>
</body>
</html>
//php文件
<?php
$user=($_POST['u']);
$pass=($_POST['p']);
$con=mysqli_connect('127.0.0.1','root','root','test');
mysqli_query($con,"set names 'utf8'");
$sql="select * from testtable WHERE(username=$user)AND(password='$pass')";
$re=mysqli_query($con,$sql);
$rs=mysqli_fetch_array($re);
if(!$re){
echo "what?";
}
if(!empty($rs)){
echo "ok";
}else{
echo "no";
}
mysqli_close($con);
?>
打赏我,让我更有动力~
© 2016 - 2024 掌控者 All Rights Reserved.
Track-方丈
发表于 2018-9-6
通过,金币奖励已发放。
评论列表
加载数据中...