当前位置:编程学习 > php >>

[原创]ajax 实现用户注册功能教程一

//

本教程由本站原创,转载请注明来处

作者:www.drise.cn

邮箱:drise@163.com

QQ:271728967

//

 

第一步我们来创建一个注册文章reg.php

第二步就是写js文件

第三步就是在用户名框使用onblur()调用type.php文件

第四步就是check.php实现文件

下面废话就不多说了,我们来建立文章reg.php代码如下[测试页面http://www.drise.cn/reg.php]

<table width="100%" border="0" cellspacing="0">
                        <form name="form1" id="form1" method="post" action="/boke/blog/check.php">
                          <tr>
                            <td height="28" colspan="5"><div id="reglist">让你不再为写博客而写博客,我们让你写的文章变成你想要的东西!</div></td>
                          </tr>
                          <tr>
                            <td height="43" colspan="3" align="left" valign="bottom"> <img src="/boke/blog/Pic/st-0136.gif" width="16" height="16" /><span class="style6">[注:带<span class="style1">*</span>号的为必须填项]</span> </td>
                            <td width="323"> </td>
                            <td width="248"> </td>
                          </tr>
                          <tr class="tb">
                            <td width="108" height="40" align="right" class="tb">用户名(<span class="style3"><span class="style1">*</span></span>):</td>
                            <td colspan="2" align="left" class="tb"><input name="xm" type="text" id="xm" size="15" onblur="ajax();" />
                            </td>
                            <td width="323" class="tb"  ><div id="divxm">
                                <div id="bothlist">请填写你的帐号!</div>
                            </div></td>
                            <td width="248" class="tb"  > </td>
                          </tr>
                          <tr class="tb">
                            <td width="108" height="40" align="right" class="tb">性别(<span class="style3"><span class="style1">*</span></span>):</td>
                            <td colspan="2" align="left" class="tb"><select name="易做图" id="易做图">
                                <option value="1">男</option>
                                <option value="0">女</option>
                            </select></td>
                            <td width="323" class="tb" ><div id="bothlist">请选择你的性别!</div></td>
                            <td width="248" class="tb" > </td>
                          </tr>
                          <tr>
                            <td width="108" height="40" align="right">用户密码(<span class="style3"><span class="style1">*</span></span>):</td>
                            <td colspan="2" align="left"><input name="rpwd" type="password" id="rpwd" size="15"  onblur="checkuser();" /></td>
                            <td width="323" rowspan="2" id="divpwd" ><div id="bothlist">请填写您的密码,长度在6-10位之间!</div></td>
                            <td width="248" rowspan="2" id="divpwd" > </td>
                          </tr>
                          <tr>
                            <td width="108" height="40" align="right">再输入一次密码(<span class="style3"><span class="style1">*</span></span>):</td>
                            <td colspan="2" align="left"><input name="rpwd1" type="password" id="rpwd1" size="15" onblur="checkuser();" /></td>
                          </tr>
                          <tr class="tb">
                            <td width="108" height="40" align="right" class="tb">密码提示问题(<span class="style3"><span class="style1">*</span></span>):</td>
                            <td colspan="2" align="left" class="tb"><select name="safe" id="safe">
                                <option value="我最喜欢的动物是什么?">我最喜欢的动物是什么?</option>
                                <option value="我高中学校叫什么名字?">我高中学校叫什么名字?</option>
                                <option value="我女朋友的名字叫什么?">我女朋友的名字叫什么?</option>
                                <option value="我最喜欢的人是谁?">我最喜欢的人是谁?</option>
                            </select></td>
                            <td width="323" class="tb"> </td>
                            <td width="248" class="tb"> </td>
                          </tr>
                          <tr>
                            <td width="108" height="40" align="right">提示问题答案(<span class="style3"><span class="style1">*</span></span>):</td>
                            <td colspan="2" align="left"><input name="safean" type="text" id="safean" size="15"  onblur="checkuser();" /></td>
                            <td width="323" id="divda" ><div id="bothlist">请填写您的答案,找回密码需要确认.例如:我叫张三!</div></td>
                            <td width="248" id="divda" > </td>
                          </tr>
                          <tr class="tb">
                            <td width="108" height="40" align="right" class="tb">您的电子邮箱(<span class="style3"><span class="style1">*</span></span>):</td>
                            <td colspan="2" align="left" class="tb"><input name="email" type="text" id="email" size="15" onblur="checkuser();" /></td>
                            <td width="323" class="tb" id="divemail"><div id="bothlist">请正确填写你的邮箱地址!</div></td>
                            <td width="248" class="tb" id="divemail"> </td>
                          </tr>
                          <tr>
                            <td width="108" height="40" align="right">验证码(<span class="style3"><span class="style1">*</span></span>):</td>
                            <td width="79" align="left"><input name="rver" type="text" id="rver" size="7"  onblur="checkuser();" /></td>
                            <td width="122" align="left"><img src="/boke/blog/inc/verlog.php" onclick="this.src='/boke/blog/inc/verlog.php';" /><span class="read">点击图片刷新</span></td>
                            <td width="323" id="divyz"><div id="bothlist">请按左边的图输入验证码,如不清楚可点击图片刷新验证码!</div></td>
                            <td width="248" id="divyz"> </td>
                          </tr>
                          <tr align="left">
                            <td width="108" height="40" class="tb"> </td>
                            <td height="40" colspan="4" class="tb"><input name="cbox" type="checkbox" id="cbox" value="1" checked="checked" />
                                <span class="phperblog_photo style4"><a href="#" class="name"><<我同意本站服务条款>></a></span></td>
                          </tr>
                          <tr>
                            <td width="108" height="40"> </td>
                            <td height="40" colspan="2" align="left"><input name="imageField" type="image" src="/boke/blog/Pic/an0159.gif" width="149" height="27" onclick=" return checkuser();" border="0" /></td>
                            <td width="323" height="40" align="left"> </td>
                            <td width="248" align="left"> </td>
                          </tr>
                                           <tr>
                            <td width="108" height="28"> </td>
                            <td height="28" colspan="2"> </td>
                            <td width="323" height="28"> </td>
                            <td width="248"> </td>
                          </tr>
                        </form>
          </table>

补充:Php教程,Php入门
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,