Registration section:
Registration Step 1:class/register_step1.php
<title>Class Address Book-registration first step</title>
Include "config.php";
if ($Submit) {
$answers 1=trim ($answers 1);
$answers 2=trim ($answers 2);
if (! ( $answers 1== $answer 1) | |! ($answers 2== $answer 2)) {
echo "Answer the wrong!" Return ";
Exit
}
Echo answered correctly and entered the second step. ";
Exit
}
?>
|
Registration first Step-authentication
|
Please answer the following questions
I really can't remember, ask the administrator.
|
Registration Step 2:class/register_step2.php
<title>Class 94 1 Contacts-Register the second step</title>
if (! $answer = = "Right") {//page protection
echo "Please don't be opportunistic!" ";
Exit
}
Include "config.php";
if ($submit) {
if (! $username | |! $PSW | |! $PSW 2| |! $name | |! $ad | |! $ph | |! $email) {//check if complete
echo "Sorry, you 2 must fill in all items with *!"
"." Return ";
Exit
}
$username =trim ($username);
$PSW =trim ($PSW);
$PSW 2=trim ($PSW 2);
$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 the trailing spaces and HTML tags
$signature =strip_tags (Trim ($signature));
Verify that 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!" "." Re-fill the "." Forget the password, ask the administrator for the password ";
Exit
}
Verify that the user name is being 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 by someone
if (mysql_num_rows ($result)!=0) {
echo "This username has already been used!" "." Re-fill ";
Exit
}
Check that the password is duplicated correctly
if (! $psw = = $PSW 2) {
echo "Please confirm password, return";
Exit
}
Check the legality of 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 not legal!
"." Re-fill
";
Exit;}
Write to 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 congratulatory message
$subject = "Congratulations on your successful registration". $sitename. "! ";//Theme
$message = $name. "Hello:
Congratulations on your successful registration yearbook! Your user name is ". $username." And the password is ". $psw."
Login now $sitename ";//letter Content
$headers. = "content-type:text/html; Charset=gb2312n "; Mime type
Mail ($email, $subject, $message, $headers);//offline debugging, this sentence may be error, do not have to control it, upload to the server.
echo "Congratulations on your successful registration!" A welcome letter has been sent to your e-mail, please pay attention to check. "," Login Now ";
Exit
}
?>
|
Sign up for step two-fill in your profile
Be careful not to have spaces, items with * are required.
|
|
The above describes the yearbook six, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.