Part 6 registration:
Registration Step 1: class/register_step1.php
Class address book-registration step 1
Include "config. php ";
If ($ Submit ){
$ Answers1 = trim ($ answers1 );
$ Answers2 = trim ($ answers2 );
If (! ($ Answers1 ==$ answer1) |! ($ Answers2 = $ answer2 )){
Echo "an error occurred! Return ";
Exit;
}
Echo "the answer is correct. go to step 2. ";
Exit;
}
?>
|
Registration Step 1-authentication |
Please answer the following questions I really cannot remember it. ask the administrator. |
Registration Step 2: class/register_step2.php
Level 94 class 1 address book-step 2 of registration
If (! $ Answer = "right") {// page protection
Echo "Please do not speculate! ";
Exit;
}
Include "config. php ";
If ($ submit ){
If (! $ Username |! $ Psw |! $ Psw2 |! $ Name |! $ Ad |! $ Ph |! $ Email) {// check whether it is complete
Echo "Sorry, you 2 must fill in all projects!
"." Back ";
Exit;
}
$ Username = trim ($ username );
$ Psw = trim ($ psw );
$ Psw2 = trim ($ psw2 );
$ Name = trim ($ name );
$ Birth = $ year. '-'. $ month. '-'. $ day;
$ Work = trim ($ work );
$ Ad = trim ($ ad );
$ Post = trim ($ post );
$ Ph = trim ($ ph );
$ Bp = trim ($ bp );
$ Email = trim ($ email );
$ Oicq = trim ($ oicq );
$ Account = strip_tags (trim ($ account); // remove spaces and html tags
$ Signature = strip_tags (trim ($ signature ));
// Check whether the name has been registered
$ Result = mysql_query ("SELECT name FROM user where name = '$ name'", $ db );
If (mysql_num_rows ($ result )! = 0 ){
Echo "this name has already been registered! "." Fill in again "." forget the password and ask the administrator for the password ";
Exit;
}
// Check whether the user name is used
$ Result = mysql_query ("SELECT user FROM user where user = '$ username'", $ db); // if the number of returned columns is not 0, this user name is already used
If (mysql_num_rows ($ result )! = 0 ){
Echo "this user name is already in use! "." Enter again ";
Exit;
}
// Check whether the password already exists
If (! $ Psw = $ psw2 ){
Echo "confirm the password and return ";
Exit;
}
// Check the validity of the email
If (! Ereg ('^ [-! # $ % & '* +./0-9 =? A-Z ^ _ 'a-z {|} ~] + '.'@'.'[-! # $ % & '* + \/0-9 =? A-Z ^ _ 'a-z {|} ~] + .'.'[-! # $ % & '* + \./0-9 =? A-Z ^ _ 'a-z {|} ~] + $ ', $ Email) & $ email ){
Echo "email is invalid!
"." Refill
";
Exit ;}
// Write data to the database
$ SQL = "INSERT INTO user (user, psw, name, sex, birth, work, ad, post, ph, bp, email, oicq, account, signature, face) VALUES ('$ username',' $ psw', '$ name',' $ sex', '$ birth', '$ work',' $ ad ', '$ post',' $ ph ',' $ bp ',' $ email ',' $ oicq ',' $ account ',' $ signature ',' $ face ') ";
$ Result = mysql_query ($ SQL, $ db );
Mysql_close ($ db );
// Send a congratulation email
$ Subject = "Congratulations on your successful registration". $ sitename ."! "; // Topic
$ Message = $ name. ", hello:
Congratulations! Your username is ". $ username." and the password is ". $ psw ."
Log on to $ sitename "; // mail content
$ Headers. = "Content-Type: text/html; charset = gb2312n"; // Mime type
Mail ($ email, $ subject, $ message, $ headers); // when debugging in offline status, this sentence may cause an error and can be uploaded to the server without worrying about it.
Echo "Congratulations! you registered successfully! A welcome letter has been sent to your mailbox. check it carefully. "," Log On Now ";
Exit;
}
?>
|
Step 2: enter personal information Note that there are no spaces. the project with * is required. |
|