<!-- html -->
1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8" /> 5 <title>Document</title> 6 </head> 7 <body> 8 <form action="check.php" method="post"> 9 <p> 10 <input type="text" name="username" value="用户名"> 11 </p> 12 <p> 13 <input type="password" name="pwd" value="密码" placeholder="密码"> 14 </p> 15 <p> 16 <input type="submit"> 17 </p> 18 </form> 19 </body> 20 </html>
<!-- php -->
1 <?php 2 $username = $_POST['username']; 3 $password = $_POST['pwd']; 4 5 $link = mysqli_connect('localhost:3308', 'root', '123456', 'mytest1'); 6 mysqli_set_charset($link, 'utf8'); 7 8 $result = mysqli_query($link, "SELECT * FROM userinfo WHERE username='{$username}' AND password='{$password}'"); $ a9 = Mysqli_num_rows ( $ result ); // judged result by the length (number 0or1) if there is found data 10 // print_r ($ result); . 11 $ Row = mysqli_fetch_array ( $ result ); // FETCH data, in order to find We need specific information 12 IF ( $ NUM == 1 ) { 13 echo "You have successfully landed," ; 14 echo ( $ Row ? [ 'isVIP']) 'our beloved members! ': 'Hello there! ' ; 15 } the else { 16 print_r (' username or password ' ); 17 } 18 ?>