<?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>
以上就介紹了登陸介面模擬02-login頁面,包含了方面的內容,希望對PHP教學有興趣的朋友有幫助。