reg.php
Copy CodeThe code is as follows:
<title>Registration page</title>
error_reporting (0);
Do not let PHP report the wrong language occurs. If not shut down well there's something like this wrong language Warning:preg_match () close will not appear
Session_Start ();
Header ("Cache-control:private");
$conn = @ mysql_connect ("localhost", "root", "") or Die ("Database connection error");
mysql_select_db ("BBS", $conn);
mysql_query ("Set names UTF8");
if ($_post[' submit '))
{
$username = $_post["username"];
$sql = "Select UserName from User_info where username= ' $username '";
Echo $sql;
$query =mysql_query ($sql);
$rows = mysql_num_rows ($query);
if ($rows > 0) {
echo "";
}else{
$user _in = "INSERT into User_info (username,pass,sex,qq,email,img) VALUES (' $_post[username] ', MD5 (' $_post[pass] '), ' $_ Post[sex] ', ' $_post[qq] ', ' $_post[email] ', ' $_post[img_select] ';
echo $user _in;
mysql_query ($user _in);
echo "";
}
Javascript:history.go (-1)
}
?>
Func.js
Copy CodeThe code is as follows:
Change the picture based on the drop-down box
function Img_change (thisobj) {
var imgsrc = "/bbs/img/" + thisobj.value+ ". gif";
document.getElementById ("Tx_change"). Src=imgsrc;
}
Check whether all registration requirements are met
function Check_reg ()
{
if (Check_len () && check_pass () && check_email () && check_qq ())
{
return true;
}else{
return false;
}
}
Check password length not less than 6
function Check_len (thisobj) {
if (thisobj.value.length==0)
{
document.getElementById (' Show_pass '). innerhtml= "Password cannot be empty";
return false;
}else{
if (thisobj.value.length<6)
{
document.getElementById (' Show_pass '). innerhtml= "Password length not less than 6";
return false;
}
document.getElementById (' Show_pass '). innerhtml= "";
return true;
}
}
Check that the password input is consistent between two times
function Check_pass (thisobj) {
var Psw=document.getelementbyid (' Pass ');
if (psw.value.length==0)
{
document.getElementById (' Show_pass '). innerhtml= "Password cannot be empty";
return false;
}else{
document.getElementById (' Show_pass '). innerhtml= "";
if (Thisobj.value!=psw.value)
{
document.getElementById (' Show_repass '). innerhtml= "Two times password input is incorrect";
return false;
}
document.getElementById (' Show_repass '). innerhtml= "";
return true;
}
}
Check if email is correct
function Check_email (thisobj) {
var reg=/^ ([A-za-z\d][a-za-z0-9_]+@[a-za-z\d]+ (\.[ a-za-z\d]+) +) $/gi;
var rzt=thisobj.value.match (REG);
if (thisobj.value.length==0) {
document.getElementById (' Show_e '). innerhtml= "Email cannot be empty";
return false;
}else{
if (rzt==null)
{
document.getElementById (' Show_e '). Innerhtml= "Email address is incorrect";
return false;
}
document.getElementById (' Show_e '). innerhtml= "";
return true;
}
}
Check QQ format is correct
function Check_qq (thisobj) {
var Qq=document.getelementbyid (' QQ '). Value;
var reg=/^\d+$/;
if (Qq.search (REG))
{
document.getElementById (' Show_qq '). Innerhtml= "QQ can only be digital";
return false;
}else{
document.getElementById (' Show_qq '). innerhtml= "";
return true;
}
}
Author: sweet__smile
http://www.bkjia.com/PHPjc/325654.html www.bkjia.com true http://www.bkjia.com/PHPjc/325654.html techarticle reg.php Copy Code code as follows:! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "HTML xmlns=" Http://www.w3 ....