Learning PHP, just read the actual walkthrough to write a login page
1. Form resolution diagram
This is what we're going to write.
First use HTML to write a form first
<HTML><Head><title>Login</title><style>#dog {text-align:center;}</style></Head><Body><DivID= "Dog"><formMethod= "POST"Action= "login.php">log in to admin<BR>Account Number:<inputtype= "username"name= "username"><BR>Password:<inputtype= "Password"name= "UPass"><BR><inputtype= "Submit"value= "Login"></form></Div></Body><HTML>
Login Form diagram:
PHP Source code
<?Php
Bloggers have not learned SQL for a while, so use the meta-ancestor to temporarily replace$userpass=Array(' admin ', ' 123456 ' );
Determine if username and password are emptyif(!$_post[' Username ']| | !$_post[' UPass ']){ Echo"Please enter your account password";}Else{
Not empty to determine if the password is correct$username=$_post[' username ']; $password=$_post[' UPass '];if($userpass[$username]==$password){ Echo"$usernameHello;}Else{ Echo"The account password is not correct"; }}?>
PHP to write a simple login page