Php user registration page code this User Registration Program is a database, registration page, registration js verification is a complete and rational php + mysql practical user registration code.
Php tutorial user registration page code
This user registration program includes a database tutorial and registration page. The registration webpage special effect verification is a complete php + mysql tutorial practical user registration code.
*/
$ Conn = mysql_connect ('localhost', 'root', 'root') or die ('database connection error ');
Mysql_select_db ('Demo', $ conn );
Mysql_query ("set names 'gbk '");
// Check whether the member name exists
If ($ _ post [username]) {
$ SQL = "select * from users where username = '$ _ post [username]'";
$ Res = mysql_query ($ SQL) or die ("query failed! ");
$ Us = $ _ get [name];
Echo $ us. "222222 ";
$ Pstutorial = md5 ($ _ post [password]);
$ Sex = $ _ post ['sex '];
$ Age = $ _ post ['age'];
$ Qq =$ _ post ['qq'];
$ Phone = $ _ post ['phone'];
$ Email = $ _ post ['email '];
$ Address = $ _ post ['address'];
If (is_array (mysql_fetch_row ($ res ))){
Echo "This member name already exists! ";
} Else {
$ SQL = "insert into users (username, password, sex, age, qq, phone, email, address) values ('$ use',' $ ps ', $ sex, $ age, $ qq, '$ phone', '$ email', '$ address ')";
Echo $ SQL;
Mysql_query ($ SQL) or die ("registration failed ");
Echo "<script> alert ('registered successfully'); location. href = 'login. php' </script> ";
}
}
?>
<Script language = "webpage effect" type = "text/javascript">
Function docheck (){
Var username = document. regform. username. value;
Var pwd = document. regform. password. value;
Var repwd = document. regform. repassword. value;
If (username = ""){
Alert ("Enter the user name! ");
Return false;
}
If (pwd = ""){
Alert ("enter the password! ");
Return false;
}
If (repwd! = Pwd ){
Alert ("the two passwords are different! ");
Return false;
}
}
</Script>
<Script language = "javascript">
Function createxmlhttprequest (){
Var xmlhttp;
If (window. activexobject ){
Xmlhttp = new activexobject ("microsoft. xmlhttp ");
} Else {
Xmlhttp = new xmlhttprequest ();
}
// Return xmlhttp;
}
Function checkname (){
Var name = document. getelementbyid ('username'); // obtain the username text box
Var span = document. getelementbyid ('name _ info'); // obtain the span tag used to display the result.
If (name. value. length <= 4 ){
Span. style. color = '# ff0000'; // set the font color in the span tag to red.
Span. innerhtml = 'username length cannot be less than 4 characters! '; // Content marked by span
Return false;
}
Var xmlhttp = createxmlhttprequest (); // create an asynchronous request object
Var time = new date (). gettime ();
Var url = 'regval. php? Name = '+ name. value +' & tmp = '+ time; // construct the request address
Xmlhttp. open ("get", url, true); // create an asynchronous request
// Here we use get request
Xmlhttp. onreadystatechange = function () {// monitor the Request status
Span. style. color = '# ff9900 ';
Span. innerhtml = 'querying... please wait! ';
If (xmlhttp. readystate = 4 & xmlhttp. status = 200 ){
Alert (xmlhttp. responsetext + "........");
If (xmlhttp. responsetext. indexof ('no ')! =-1) {// if no is returned by the server
Span. style. color = '# cb2121'; // set the color of the span tag to red.
Span. innerhtml = 'user name ['+ name. value +'] has been used by other users! ';
// Document. regform. username. value = "";
} Else {// if no
Span. style. color = '#00a800'; // set the color to green.
Span. innerhtml = 'congratulations, this user name is not registered! ';
}
Return true;
Delete xmlhttp; // delete a request object
}
}
Xmlhttp. send (null); // send a request
}
</Script>
<Form action = "regval. php" method = "post" onsubmit = "return docheck ()" name = "regform">
Member Name:
<Input type = "text" name = "username" value = "" id = "username" onblur = "checkname ()"/>
<Span id = "name_info"> </span>
<Br>
Password & nbsp; Code:
<Input type = "password" name = "password" value = ""/> <br>
Confirm Password:
<Input type = "password" name = "repassword" value = ""/> <br>
Gender:
Male: <input name = "sex" type = "radio" value = "0" checked = "checked"/>
Female: <input name = "sex" type = "radio" value = "1"/> <br>
Age: <input type = "text" name = "age" value = "/> <br>
Qq: <input type = "text" name = "qq" value = "/> <br>
Tel: <input type = "text" name = "phone" value = "/> <br>
Email: <input type = "text" name = "email" value = "/> <br>
Address: <input type = "text" name = "address" value = "/> <br>
<Input type = "submit" name = "sub" value = "register"/>
<Input type = "reset" name = "re" value = "cancel"/>
</Form>
<?
/*
Drop table if exists 'users ';
Create table 'users '(
'Id' int (10) not null auto_increment,
'Username' varchar (50) not null,
'Password' varchar (50) not null,
'Sex' int (1) not null default '0 ',
'Age' int (10) not null,
'Qq' int (15) default null,
'Phone' varchar (50) default null,
'Email 'varchar (50) default null,
'Address' varchar (100) default null,
Primary key ('id ')
) Engine = innodb auto_increment = 4 default charset = gbk;
------------------------------
-- Records of users
------------------------------
Insert into 'users' values ('1', 'admin', '21232f297a57a5a743894a0e4a801fc3', '0', '22', '123456', '1234568 ', '1970 @ 163.com ', 'wuhan ');
Insert into 'users' values ('2', 'root', '63a9f0ea7bb98050796b649e85481845 ', '0', '20', '123', '123', '123 ', '1970 @ 163.com ', 'China ');
Insert into 'users' values ('3', 'www. bKjia. c0m', '96e79218965eb72c92a549dd5a330112 ', '0', '20', '000000', '000000', '2017 @ 163.com', 'China ');
This tutorial
Http://down.bKjia. c0m/down/code/php/xinwenxitong/2010/0812/20183.html