Php helps me to see if there are errors in lines 16 and 17 in the receive file, and an error will be reported when I register the same user name-php Tutorial

Source: Internet
Author: User
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 ("

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.