怎样用JavaScript实现html的登录注册?

对这个语言不是很懂。希望详细些,最好有可以运行的文档。

直接把它放在body标签里就可以的,你试试吧,要是用不了联系我~~~ <table><tr>
<td width="45" height="63" align="center" valign="middle"><img src="images/left_b02.jpg" width="39" height="54"></td>
<td width="3" height="63"><img src="images/left_b01.jpg" width="3" height="63"></td>
<td height="63"><table width="103%" height="108" border="0" cellpadding="0" cellspacing="0">
<%
If Not Isempty(Request("login")) Then
str1=Str_filter(Request.Form("txt_name"))
str2=Str_filter(Request.Form("txt_passwd"))
str3=Str_filter(Request.Form("cb_auto"))
Set rs=conn.Execute("select Uname,Upasswd from tab_user_reg where Uname='"&str1&"'")
If rs.eof Then
Response.Write("<script lanuage='javascript'>alert('您输入的用户名不正确,请重新输入!');</script>")
Else
If rs("Upasswd")<>str2 Then
Response.Write("<script lanuage='javascript'>alert('您输入的密码不正确,请重新输入!');</script>")
Else
Session("Uname")=rs("Uname")
Response.Write("<script lanuage='javascript'>location.href='User_center.asp';</script>")
End If
End If
End If
%>
<form name="form_login" method="post" action="">
<tr>
<td width="32%" height="22" align="left">用户名:</td>
<td width="38%" height="22"><input name="txt_name" type="text" class="textbox" id="txt_name" size="10"></td>
</tr>
<tr>
<td height="22" align="left">密 码:</td>
<td height="22"><input name="txt_passwd" type="password" class="textbox" id="txt_passwd" size="10"></td>
<td align="center"><input name="login" type="submit" class="button" id="login" value="登录" /></td>
</tr>
<tr align="center">
<td height="22" colspan="1">
<input type="button" name="Submit2" value="注册" class="button" onClick="javascript:window.open('User_reg.asp','new','height=410,width=580');"> </td><td height="22" colspan="1">
<input type="button" name="Submit3" value="找回密码" class="button" onClick="javascript:window.open('User_get_passwd.asp','new','height=220,width=570');"></td>
</tr></table>
温馨提示:答案为网友推荐,仅供参考
第1个回答  2013-08-05
<style type="text/css">
<!--
body,td,th {
font-family: 宋体;
font-size: 14px;
}
.STYLE1 {
font-size: 24px;
font-weight: bold;
}
-->
</style><p align="center" class="STYLE1">个人资料补填</p>
<table width="400" border="3" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000" bgcolor="#99CCFF">
<tr>
<td width="96" height="30" align="center">姓名</td>
<td width="96" height="30" align="center"> </td>
<td width="97" height="30" align="center">性别</td>
<td width="97" height="30" align="center"> </td>
</tr>
<tr>
<td height="30" align="center">学号</td>
<td height="30" align="center"> </td>
<td height="30" align="center">出生日期</td>
<td height="30" align="center"> </td>
</tr>
<tr>
<td height="30" align="center">班级</td>
<td height="30" align="center"> </td>
<td height="30" align="center">专业</td>
<td height="30" align="center"> </td>
</tr>
<tr>
<td height="30" colspan="2" align="center"> </td>
<td height="30" colspan="2" align="center"> </td>
</tr>
<tr>
<td height="30" colspan="2" align="center"> </td>
<td height="30" colspan="2" align="center"> </td>
</tr>
<tr>
<td height="30" colspan="2" align="center"> </td>
<td height="30" colspan="2" align="center"> </td>
</tr>
</table>
第2个回答  2013-08-05
比较简单的,我用jQuery库,可从www.jquery.com下载.
HTML页面:
........
<script type = "text/javascript" src = "jquery.js"></script>
<script type = "text/javascript">
function checkUsername(){
var username = $("#username").val();
$.get("checkusername.php",{name: username},function(txt){
if(txt == 1){$("#msg").html("<p>此用户名可注册</p>");}
else {$("#msg").html("<p>此用户已经被注册注册!</p>");}
});
}
</script>
........
<input id = "username" type = "text" onchange = "checkUsername()" />
<div id = "msg"></div>
........

checkusername.php的内容:
<?php
$hosting = "localhost";//数据库地址
$username = "root";//数据库用户名
$password = "123456";//数据库密码
$database = "my_db";//数据库名
$table = "users";//表名
$name = $_GET['name'];
$link = mysql_connect($hosting ,$username,$password);
mysql_query("USE $database", $link);
$result = mysql_query("SELECT * FROM $table WHERE username='$name'", $link);
$rows = mysql_num_rows($result);
if($rows >= 1){
echo("0");
}else{
echo("1");
}
?>
第3个回答  2017-07-16
你好,首先简单的帮你说一下登录注册原理。
其实就是写入和读取的一个过程,就好像我们把东西记录在笔记本里,等我们需要核实就翻出来对一下正不正确。登录和注册也是如此,注册一个帐号,把注册的信息写入数据库中,登录的时候从数据库中拿出来验证,看输入有没有错误。判断后得出来的结果。
实现HTML的注册和登录,需要配合动态语言。单纯的javascript和jquery都不能实现的。javascript可作为前台的判断语言,配合后台代码执行。
动态语言有:jsp,php,asp,net等等。而现在比较流行的动态语言有PHP,希望能够帮到你,谢谢。
相似回答