1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| <?php $hostname = "localhost"; $dbuser = "root" $dbpass = "toor"; $dbname = "tgfs";
$username = "Lixiney"; $password = "password";
$conn = new mysqli($hostname,$dbuser,$dbpass,$dbname); if($conn -> connect_error){ die("数据库连接错误".$conn->connect_error); } $sql = "select * from user where username = ? and password = ?";
$stmt = $conn -> prepare($sql); $stmt -> bind_param("ss",$username,$password); $stmt -> execute(); $result = $stmt -> get_result(); $row = $result->fetch_assoc(); if($result -> num_rows > 0 and $row['password'] === $password){ echo "登录成功"; header("Location: vul/index.html"); }else{ echo "登录失败"; }
?>
|