<?php session_start(); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>login</title> </head> <body> <?php $s_username = $_POST["username"]; $s_password = $_POST["password"]; $conn = new mysqli("localhost:3306","dbuser","dbpassword","dbname"); if($conn->connect_error) { die("Connection failed:".$conn->connect_error); } if($stmt=$conn->prepare("SELECT username password FROM customer WHERE username=? AND password=?")) { $stmt->bind_param("ss",$s_username,$s_password); $stmt->execute(); $stmt->bind_result($U); $HasData=false; while($stmt->fetch()) { $HasData=true; echo "你又来了,"."$s_username"; $_SESSION['token']=$s_username; } if($HasData==false) { echo "账号名或密码不存在。"; } } $conn->close(); ?> </body> </html>
The above introduces the login interface simulation 02-login page, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.