Php helps me to check if errors occur in lines 16 and 17 of the receive file. if the same user name is registered, the error "register. php" will be reported.
Register
Script
Function check (){
Var psw1 = document. getElementById ("psw1 ");
Var psw2 = document. getElementById ("psw2 ");
If (psw1.value! = Psw2.value)
Psw2.setCustomValidity ("two passwords inconsistent ");
Return false;
}
Script
Login | registration
Welcome to registration
User name:
Password & nbsp code:
Confirm password:
Mail & nbsp box:Placeholder = "enter the correct email format" name = "email">
Verification code:
Require ('yzm. php ');
?>
I have read and agree to this agreement
Book terms
Receive. php
If (isset ($ _ POST ['submit ']) {
Session_start ();
$ Checkstr = $ _ SESSION ['yzm']; // use the $ _ SESSION variable to obtain the verification code on the 03. php page.
$ Str = $ _ POST ['check']; // user-input string
If (strcasecmp ($ str, $ checkstr )! = 0) // case-insensitive comparison
Echo "script" alert ('verification code is incorrect! ');
Location. href = 'Register. php'; script ";
Else {
$ Username = $ _ POST ["username"];
$ Password = $ _ POST ["psw1"];
$ Email = $ _ POST ["email"];
$ Dsn = "mysql: host = localhost; dbname = book ";
$ Db = new PDO ($ dsn, 'root', '123 ');
$ Db-> query ('set names utf8 ');
Row 16: $ chkusername = mysql_query ("select username from register where username =". $ username ."");
Row 17: $ numrow = mysql_num_rows ($ chkusername );
If ($ numrow! = 0 ){
Print ("