register.php
<title>Registered</title>
Sign In | register
Welcome to Register
User name:
Secret code:
Confirm Password:
Mail box:
Placeholder= "Please enter the correct email format" name= "email" >
Verification Code:
Require (' yzm.php ');
?>
I have read and agree to the agreement
"Book" clause
receive.php
if (Isset ($_post[' submit ')) {
Session_Start ();
$checkstr = $_session[' Yzm '); Use the $_session variable to get the verification code on the 03.php page
$str = $_post[' Check ']; User-entered string
if (strcasecmp ($STR, $checkstr)! = 0)//case-insensitive comparison
echo "";
else {
$username = $_post["username"];
$password = $_post["PSW1"];
$email = $_post["email"];
$DSN = "Mysql:host=localhost;dbname=book";
$db =new PDO ($dsn, ' root ', ' 123456 ');
$db->query (' Set names UTF8 ');
16 rows: $chkusername = mysql_query ("Select username from register where username=". $username. ");
17 rows: $numrow = mysql_num_rows ($chkusername);
if ($numrow! = 0) {
Print ("
");
}
else {
$sql = "INSERT into register (username,password,email) VALUES (?,?,?)";
$stmt = $db->prepare ($sql);
$stmt->bindparam (1, $username);
$stmt->bindparam (2, $password);
$stmt->bindparam (3, $email);
$stmt->execute ();
$_session[' username '] = $username;
Print ("
");
}
}
}
else echo "illegal access";
?>
Reply to discussion (solution)
This is how you connect to the database.
$DSN = "Mysql:host=localhost;dbname=book";
$db =new PDO ($dsn, ' root ', ' 123456 ');
$db->query (' Set names UTF8 ');
And then you do it.
16 rows: $chkusername = mysql_query ("Select username from register where username=". $username. ");
17 rows: $numrow = mysql_num_rows ($chkusername);
Do you think it would be appropriate to do so?
The SQL statement also needs to be changed, unless your username is a number, you need to add a single quotation mark
$sql = "Select username from register where username = ' {$username} '";
Link PDO is used with native
17 line How to change, who can give a changed 16 line, 17 line out to me to see
Finally changed the good!
You're using the PDO connection. Executing SQL with native methods is bound to go wrong.