PHP User Registration (front desk perfect JS verification)

Source: Internet
Author: User
Tags mysql tutorial

/*
CREATE TABLE ' member ' (
' member_account ' varchar collate utf8_unicode_ci NOT NULL,
' Member_password ' varchar collate utf8_unicode_ci NOT NULL,
' member_name ' varchar collate utf8_unicode_ci NOT NULL,
' Sex ' varchar (1) Collate utf8_unicode_ci NOT NULL,
' Schoolnumber ' varchar (a) collate utf8_unicode_ci NOT NULL,
' PhoneNumber ' varchar collate utf8_unicode_ci NOT NULL,
' Email ' varchar collate utf8_unicode_ci NOT NULL,
Unique key ' Member_account ' (' Member_account ')
) Engine=innodb default Charset=utf8 collate=utf8_unicode_ci;

*/
?>

The code is as follows Copy Code

<!doctype HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/ Xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title> Member Registration </title>

<body>
<div align= "center" ><font face= "regular script" size= "+3" > Member Registration </font></div>
<form id= "Form1" Name= "Form1" method= "Get" action= "register_get.php" >
<table width= "695" border= "1" align= "center" cellpadding= "1" cellspacing= "1" >
<tr>
&LT;TD width= "167" > Account: (Accounts) </td>
&LT;TD width= "416" ><input name= "M_acct" type= "text" id= "M_acct" value= "<?php if (!empty ($_get[' M_acct '))
echo $_get[' M_acct '];
?> "Maxlength="/>
<font color= "#ff0000" > *</font> (consisting of 20 digits or letters) </td>
</tr>
<tr>
<td> Password: (password) </td>
<td><input name= "M_PW" type= "password" id= "M_PW" maxlength= "/>"
<font color= "#ff0000" > *</font> (consisting of 20 digits or letters) </td>
</tr>
<tr>
<td> Confirmation Password (password) </td>
<td><input type= "password" name= "pass" id= "pass"/>
<font color= "#ff0000" > *</font> (enter password again) </td>
</tr>
<tr>
<td> real name: (name) </td>
<td><input type= "text" name= "M_name" id= "M_name" value= "<?php if (!empty ($_get[' m_name '))
echo $_get[' M_name '];
?> "/></td>
</tr>
<tr>
<td> sex: (Sex) </td>
&LT;TD align= "left" ><p>
<label>
<input name= "M_sex" type= "Radio" id= "RADIOGROUP1_0" value= "male"/>
Male </label>
<label>
<input type= "Radio" name= "M_sex" value= "female" id= "Radiogroup1_1"/>
Female &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color= "#ff0000" > *</font></ Label>
</td>
</tr>
<tr>
<td> No.: (School Number) </td>
<td><input type= "text" name= "M_snum" id= "M_snum" value= "<?php if (!empty ($_get[' m_snum '))
echo $_get[' M_snum '];
?> "/></td>
</tr>
<tr>
<td> Mobile Number: (Mobil phone) </td>
<td><input type= "text" name= "M_pnum" id= "M_pnum" value= "<?php if (!empty ($_get[' m_pnum '))
echo $_get[' M_pnum '];
?> "/></td>
</tr>
<tr>
<td> e-mail: (email) </td>
<td><input type= "text" name= "M_email" id= "M_email" value= "<?php if (!empty ($_get[' M_email '))
echo $_get[' M_email '];
?> "/></td>
</tr>
<tr>
&LT;TD colspan= "2" align= "center" ><input type= "reset" name= "button" id= "button" value= "Reset form"/>
<input type= "Submit" Name= "Button2" id= "Button2" value= "Confirm registration"/></td>
</tr>
</table>
</form></p>
<p align= "center" > Above "*" are required </p>
</body>

register_get.php file
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title> Tips </title>
<?php
if (Empty ($_get[' M_acct '))
echo "Account cannot be empty!" <a href= ' register.php?m_name= '. $_get[' M_name '. " &m_sex= ". $_get[' M_sex ']." &m_snum= ". $_get[' M_snum ']." &m_pnum= ". $_get[' M_pnum ']." ' > Return to register again. </a></p> ";
else if (Empty ($_get[' M_PW '))
echo password cannot be empty! <a href= ' register.php?m_acct= '. $_get[' M_acct '. " &m_name= ". $_get[' M_name ']." &m_sex= ". $_get[' M_sex ']." &m_snum= ". $_get[' M_snum ']." &m_pnum= ". $_get[' M_pnum ']." &m_email= ". $_get[' M_email ']." ' > Return to register again. </a></p> ";
else if ($_get[' M_PW ']!=$_get[' pass ')]
echo "Two input passwords are not the same, <a href= ' register.php?m_acct=". $_get[' M_acct '. " &m_name= ". $_get[' M_name ']." &m_sex= ". $_get[' M_sex ']." &m_snum= ". $_get[' M_snum ']." &m_pnum= ". $_get[' M_pnum ']." ' > Return to register again. </p> ";
else if (Empty ($_get[' m_sex '))
echo "Did not enter gender, <a href= ' register.php?m_acct=". $_get[' M_acct '. " &m_name= ". $_get[' M_name ']." &m_snum= ". $_get[' M_snum ']." &m_pnum= ". $_get[' M_pnum ']." ' > Return to register again. </a></p> ";
else if (!empty ($_get[' m_snum ')) &&!is_numeric ($_get[' m_snum '))
echo "Learning number must be all numbers, <a href= ' register.php?m_acct=". $_get[' M_acct '. " &m_name= ". $_get[' M_name ']." &m_sex= ". $_get[' M_sex ']." &m_pnum= ". $_get[' M_pnum ']." ' > Return to register again. </a></p> ";
else if (!empty ($_get[' m_pnum ')) &&!is_numeric ($_get[' m_pnum '))
echo "Cell phone number must be all numbers, <a href= ' register.php?m_acct=". $_get[' M_acct '. " &m_name= ". $_get[' M_name ']." &m_sex= ". $_get[' M_sex ']." &m_snum= ". $_get[' M_snum ']." ' > Return to register again. </a></p> ";
else if (!empty ($_get[' M_email ')) &&!ereg ([0-9a-za-z]+) ([@]) ([0-9a-za-z]+) (.) ([0-9a-za-z]+) ", $_get[' M_email '])
echo "Mailbox input is illegal! <a href= ' register.php?m_acct= '. $_get[' M_acct '. " &m_name= ". $_get[' M_name ']." &m_sex= ". $_get[' M_sex ']." &m_snum= ". $_get[' M_snum ']." &m_pnum= ". $_get[' M_pnum ']." ' > Return to register again. </a></p> ";
Else
{
Require_once (' inc.php ');
$_session[' Pass ']= "OK";
$_session[' member ']=$_get[' M_acct '];
$link = Getdblink ();
$sql = INSERT INTO member values ('. $_get[' M_acct ']. "', '". MD5 ($_get[' M_PW '). "', '". $_get[' M_name ']. "', '" $_get[' m_ Sex ']. ', '. $_get[' m_snum '. "', '", $_get[' M_pnum '. "', '". $_get[' M_email '].
$result =mysql Tutorial _query ($sql) or Die (Mysql_error ());
if ($result >0)
echo "". $_get[' M_name '. ", congratulations on your registration success, <a href= ' member_index.php ' > immediately enter the homepage ...</p>";
Else
{
$_session[' Pass ']= "no pass";
echo "Registration failed! <a href-' register.php ' > re registered. </a></p> ";
Mysql_close ();
}
}
?>
<body>
</body>

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.