PHP user registration login system login processing page
Login processing page
The flow chart is as follows:
The code is as follows:
alert('请输入用户名或者密码!'); history.go(-1);"; }else if($code != $_SESSION[' ver_code']){ echo ""; } else { //确认用户名密码验证码不为空,则连接数据库 $conn = mysqli_connect("localhost","root","root");//数据库帐号密码为安装数据库时设置 if(mysqli_errno($conn)){ echo mysqli_errno($conn); exit; } mysqli_select_db($conn,"userdb"); mysqli_set_charset($conn,'utf8'); $sql = "select username,userpwd from user where username = '$user' and userpwd = '$psw'"; $result = mysqli_query($conn,$sql); $num = mysqli_num_rows($result); if($num) { echo ""; } else { echo ""; } } } else { echo ""; } ?>
Code explanation:
Enter when you click login on the login page Login processing page
Determine whether the $_POST["hidden"] passed in the post method exists. If it does not exist, it will prompt that the submission was unsuccessful and return to the login interface. If it exists, continue.
Get the passed value (use the trim() function to filter blank characters, and use the md5() function to encrypt the password), and then determine whether it is empty. If it is empty, a prompt will pop up. Return to the login interface. If it is not empty, continue
Determine whether the verification code value passed by the post method is equal to the verification code value that previously existed in the session. If they are not equal, it will prompt that the verification code is incorrect. , return to the login page, if equal, continue to execute
- ## Connect to the database, select the database we created, set the character set, query the database through the user name and password, and determine whether the user name and password are Exists in the database. If it does not exist, it will prompt that the user name or password is incorrect and return to the login page. If it exists, it will prompt successful login and jump to the homepage