代码如下:
reg.asp:
<!--#includefile="../inc/web_conn.asp"-->
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=gb2312"/>
<title>Kenvi.cn</title>
<METAname="keywords"content="kenvi"/>
<METAname="description"content="kenvi.cn"/>
<linkhref="zp.css"rel="stylesheet"type="text/css"/>
<scriptlanguage="javascript"src="/inc/main.js"></script>
<styletype="text/css">
body{
margin-left:0px;
margin-top:0px;
margin-right:0px;
margin-bottom:0px;
}
.dd{width:200px;text-align:center;}
.STYLE2{
font-size:14px;
font-weight:bold;
color:#FFFFFF;
}
.z0056C2{color:#0056C2;}
</style>
<scriptlanguage="javascript">
<!--
varmsg;
varli_ok='images/li_ok.gif';
varli_err='images/li_err.gif'
varbname_m=false;
msg=newArray(
"推荐使用:·
网易邮箱 ·QQ邮箱 ·SOHU邮箱",
"请输入4-14位字符,英文、数字的组合。",
"请输入6位以上字符,不允许空格。",
"请重复输入上面的密码。",
"请输入邮箱地址"
)
//document.getElementById("d_email").innerHTML=msg[0];
//document.getElementById("d_pass").innerHTML=msg[2];
//document.getElementById("d_pass2").innerHTML=msg[3];
//document.getElementById("d_name").innerHTML=msg[1];
varxmlHttp=false;
try{
xmlHttp=newActiveXObject("Msxml2.XMLHTTP");
}catch(e){
try{
xmlHttp=newActiveXObject("Microsoft.XMLHTTP");
}catch(e2){
xmlHttp=false;
}
}
if(!xmlHttp&&typeofXMLHttpRequest!='undefined'){
xmlHttp=newXMLHttpRequest();
}
functionon_input(objname){
varstrtxt;
varobj=document.getElementById(objname);
obj.className="d_on";
//alert(objname);
switch(objname){
case"d_email":
strtxt=msg[4];
break;
case"d_name":
strtxt=msg[1];
break;
case"d_pass":
strtxt=msg[2];
break;
case"d_pass2":
strtxt=msg[3];
break;
}
obj.innerHTML=strtxt;
}
functionout_email(){
varobj=document.getElementById("d_email");
varstr=document.getElementById("ys_email").value;
varchk=true;
if(str==''||!str.match(/^[\w\.\-]+@([\w\-]+\.)+[a-z]{2,4}$/ig)){chk=false}
if(chk){
obj.className="d_ok";
obj.innerHTML='电子邮箱地址已经输入。';
document.getElementById("d_email_img").src=li_ok;
}else{
obj.className="d_err";
obj.innerHTML=msg[4];
document.getElementById("d_email_img").src=li_err;
}
returnchk;
}
functionout_upwd1(){
varobj=document.getElementById("d_pass");
varstr=document.getElementById("ys_pass").value;
varchk=true;
if(str==''||str.length<6||str.length>14){chk=false;}
if(chk){
obj.className="d_ok";
obj.innerHTML='密码已经输入。';
document.getElementById("d_pass_img").src=li_ok;
}else{
obj.className="d_err";
obj.innerHTML=msg[2];
document.getElementById("d_pass_img").src=li_err;
}
returnchk;
}
functionout_upwd2(){
varobj=document.getElementById("d_pass2");
varstr=document.getElementById("ys_pass2").value;
varchk=true;
if(str!=document.getElementById("ys_pass").value||str==''){chk=false;}
if(chk){
obj.className="d_ok";
obj.innerHTML='重复密码输入正确。';
document.getElementById("d_pass2_img").src=li_ok;
}else{
obj.className="d_err";
obj.innerHTML=msg[3];
document.getElementById("d_pass2_img").src=li_err;
}
returnchk;
}
functionchk_reg(){
varchk=true
if(document.getElementById("ys_name").value==''){chk=false;
d_name.className="d_err";
d_name.innerHTML=msg[1];
document.getElementById("d_uname_img").src=li_err;
}
if(!out_upwd1()){chk=false}
if(!out_upwd2()){chk=false}
if(!out_email()){chk=false}
if(chk){
document.getElementById('save_stat').innerHTML='<imgsrc="images/loading.gif"align="absmiddle"/>数据提交中……请稍候……'
document.getElementById('regbotton').disabled='disabled';
varusername=document.regform.ys_name.value;
varpassword=document.regform.ys_pass.value;
varrepassword=document.regform.ys_pass2.value;
varemail=document.regform.ys_email.value;
//varurl2="reg.asp?action=save&ys_name=+"escape(username)"+&password=+"escape(username)"+&email="+escape(email);
//varurl2="reg.asp?action=save&username="+escape(username)+"&password="+escape(password)+"&email="+escape(email);
xmlHttp.open("POST","saveuser.asp",true);
xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
xmlHttp.onreadystatechange=saveuser;
xmlHttp.send("username="+escape(username)+"&password="+escape(password)+"&email="+escape(email));
}
}
functionsaveuser(){
if(xmlHttp.readyState<4){
d_name.innerHTML="loading...";
}
if(4==xmlHttp.readyState){
if(200==xmlHttp.status){
vardate=xmlHttp.responseText;
if(date==1){
alert("用户注册成功!");
//window.location.href='\/exhibit';
window.location.href="reg.asp";
}else{
alert("注册发生错误!");
window.location.href="reg.asp";
}
}else{
alert("error");
}
}
}
functioncallServer(){
varu_name=document.getElementById("ys_name").value;
if((u_name==null)||(u_name=="")){
d_name.className="d_err";
d_name.innerHTML=msg[1];
document.getElementById("d_uname_img").src=li_err;
chk=false
returnchk;};
xmlHttp.open("POST","checkuser.asp",true);
xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
xmlHttp.onreadystatechange=updatePage;
xmlHttp.send("username="+escape(u_name));
}
functionupdatePage(){
if(xmlHttp.readyState<4){
d_name.innerHTML="loading...";
}
if(xmlHttp.readyState==4&&200==xmlHttp.status){
varresponse=xmlHttp.responseText;
if(response==1)
{
d_name.className="d_ok";
d_name.innerHTML='恭喜用户名可以使用。';
document.getElementById("d_uname_img").src=li_ok;
}
else{
d_name.className="d_err";
document.getElementById("d_uname_img").src=li_err;
d_name.innerHTML="用户名已占用,请重新注册";
}
}
}
-->
</script>
</head>
<body>
<!--#includefile="../top.asp"-->
<tablewidth="857"align="center"cellpadding="0"cellspacing="0">
<tr>
<tdheight="20"align="left"valign="top"> </td>
</tr>
<tr>
<tdwidth="260"height="20"align="left"valign="top"><imgsrc="images/zc-top.jpg"width="857"height="20"/></td>
</tr>
<tr>
<tdheight="20"align="left"valign="top"><tablewidth="100%"cellspacing="0"cellpadding="0">
<tr>
<tdwidth="3"bgcolor="FF7300"></td>
<tdalign="center"><formid="regform"name="regform"method="post"action="reg.asp">
<tablewidth="90%"cellspacing="0"cellpadding="0">
<tr>
<tdheight="15"colspan="4"></td>
</tr>
<tr>
<tdheight="35"colspan="4"align="left"class="blut_title">请填写注册信息:</td>
</tr>
<tr>
<tdwidth="12%"align="left"><imgsrc="images/button.jpg"width="11"height="11"id="d_email_img"/> Email:</td>
<tdwidth="30%"height="30"align="left"><inputname="ys_email"type="text"id="ys_email"size="30"onFocus="on_input('d_email')"onBlur="out_email()"/></td>
<tdwidth="42%"align="left"colspan="2"class="yellow12"id="d_email">推荐使用:·
网易邮箱 ·QQ邮箱 ·SOHU邮箱</td>
</tr>
<tr>
<tdalign="left"><imgsrc="images/button.jpg"width="11"height="11"id="d_uname_img"/> 会员名:</td>
<tdheight="30"align="left"><inputname="ys_name"type="text"id="ys_name"size="30"onFocus="on_input('d_name')"onBlur="callServer()"/></td>
<tdalign="left"class="z666_unlink"id="d_name"colspan="2">须以字母开头,至少4位</td>
</tr>
<tr>
<tdalign="left"><imgsrc="images/button.jpg"width="11"height="11"id="d_pass_img"/> 密 码:</td>
<tdheight="30"align="left"><inputname="ys_pass"type="password"id="ys_pass"size="30"onFocus="on_input('d_pass')"onBlur="out_upwd1()"/></td>
<tdcolspan="2"align="left"class="z666_unlink"id="d_pass">密码设置至少4位,请区分大小写</td>
</tr>
<tr>
<tdalign="left"><imgsrc="images/button.jpg"width="11"height="11"id="d_pass2_img"/> 重复密码:</td>
<tdheight="30"align="left"><inputname="ys_pass2"type="password"id="ys_pass2"size="30"onFocus="on_input('d_pass2')"onBlur="out_upwd2()"/></td>
<tdcolspan="2"align="left"class="z666_unlink"id="d_pass2"></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<tdheight="1"colspan="4"background="images/dian.jpg"></td>
</tr>
<tr>
<tdheight="46"colspan="4"align="center">
<label>
<!--<inputtype="image"name="regbotton"src="images/reg.jpg"onclick="chk_reg();"/>-->
<inputtype="button"name="submit"value="OK!确认提交注册信息"onclick="chk_reg();"id="regbotton">
</label><divid="save_stat"></div></td>
</tr>
</table>
</form>
</td>
<tdwidth="3"bgcolor="FF7300"></td>
</tr>
</table></td>
</tr>
<tr>
<tdheight="20"align="left"valign="top"><imgsrc="images/zc-bottom.jpg"width="857"height="11"/></td>
</tr>
</table>
<!--#includefile="../bottom.asp"-->
</body>
</html>
===================
zp.css
/*CSSDocument*/
body{font-family:"宋体";font-size:12px;color:#333333;line-height:20px;}
a:link{color:#333333;text-decoration:none;}
a:visited,a:active{text-decoration:none;color:#333333;}
a:hover{text-decoration:underline;color:#003278;}
a.blue12:link{color:#001D4C;text-decoration:none;}
a.blue12:visited,a.blue12:active{text-decoration:none;color:#001D4C;}
a.blue12:hover{text-decoration:underline;color:#FF6600;}
a.black14:link{color:#333333;text-decoration:none;font-size:14px;font-weight:bold;line-height:24px;}
a.black14:visited,a.black14:active{text-decoration:none;font-size:14px;font-weight:bold;color:#333333;line-height:24px;}
a.black14:hover{text-decoration:underline;color:#FF6600;font-size:14px;font-weight:bold;line-height:24px;}
a.title_kh:link,a.title_kh:visited{color:#333333;text-decoration:none;}
a.title_kh:hover{text-decoration:none;color:#FF6600;font-size:120%;}
a.title_kh:active{text-decoration:none;color:#FF6600;}
a.yellow:link,a.yellow:visited{color:#FF6600;text-decoration:none;}
a.yellow:hover{text-decoration:underline;color:#003278;}
a.yellow:active{text-decoration:none;color:#FF6600;}
a.tj:link,a.tj:visited{color:#FF0000;text-decoration:none;}
a.tj:hover{text-decoration:underline;color:#003278;}
a.tj:active{text-decoration:none;color:#003278;}
a.blue14:link,a.blue14:visited{color:#001D4C;text-decoration:none;font-weight:bold;font-size:14px}
a.blue14:hover{text-decoration:none;color:#FF6600;font-weight:bold;font-size:14px}
a.blue14:active{text-decoration:none;color:#001D4C;font-weight:bold;font-size:14px}
.img{border:1pxsolid#cccccc;}
.zt_table{border:1pxsolid#DDDBDB;}
.zt_title{color:#FF6600;font-weight:bold;font-size:14px;}
.blut_title{color:#003278;font-weight:bold;font-size:14px;}
.blut12_unlink{color:#003399;font-weight:bold;}
.blue{color:#003278;}
.yellow12{color:#FF3300;}
.yellow14{color:#FF3300;font-size:14px;}
.end_title{font-size:24px;font-family:"黑体";color:#003278;}
.end_zw{font-size:14px;line-height:24px;}
.z666_unlink{color:#666666;}
.wywg_nolink{color:#FF6600;font-weight:bold;font-size:14px;}
a.wywg:link,a.wywg:visited{color:#FF6600;text-decoration:underline;font-weight:bold;font-size:14px;}
a.wywg:hover{text-decoration:underline;color:#FF7F12;font-weight:bold;font-size:14px;}
a.wywg:active{text-decoration:underline;color:#FF6600;font-weight:bold;font-size:14px;}
a.zc:link,a.zc:visited{color:#FF6600;text-decoration:underline;}
a.zc:hover{text-decoration:underline;color:#FF7F12;}
a.zc:active{text-decoration:underline;color:#FF6600;}
.d_default{
padding:2px02px4px;
border:1pxsolid#f7f7f7;
}
.d_on{
padding:2px02px4px;
border:1pxsolid#FFCC00;
color:#000;
background-color:#FFFFDD;
}
.d_ok{
padding:2px02px24px;
border:1pxsolid#00BE00;
color:#000;
background:#E6FFE6url(li_ok.gif)no-repeat4px;
}
.d_err{
border:1pxsolid#F30;
color:#F00;
padding:2px02px24px;
background:#FFF1E4url(li_err.gif)no-repeat4px;
}
========================
checkuser.asp:
===========================
<!--#includefile="../inc/conn.asp"-->
<%
Response.ContentType="text/html"
Response.Charset="gb2312"
ys_name=trim(request("username"))
setrs=server.createobject("adodb.recordset")
sql="selectys_name,idfromys_imemberwhereys_name='"&ys_name&"'"
rs.opensql,conn,1,1
ifrs.bofandrs.eofthen
response.write"1"
else
response.write"0"
endif
rs.close
setrs=nothing
%>
saveuser.asp:
<!--#includefile="../inc/conn.asp"-->
<%ys_name=request("username")
ys_pass=request("password")
ys_email=request("email")
setjrs=server.CreateObject("adodb.recordset")
jsql="selectys_name,idfromys_imemberwhereys_name='"&ys_name&"'"
jrs.openjsql,conn,1,1
ifjrs.eofandjrs.bofthen
setrs=server.CreateObject("adodb.recordset")
sql="select*fromys_imemberwhereidisnull"
rs.opensql,conn,1,3
rs.addnew
rs("ys_name")=ys_name
rs("ys_pass")=ys_pass
rs("ys_email")=ys_email
rs.update
Session("ys_userame")=ys_name
rs.close
setrs=nothing
response.write"1"
else
response.write"0"
endif
jrs.close
setjrs=nothing
%>
http://www.corange.cn/archives/2008/03/456.html