asp问题:如何得到表单信息并提交到另一页面?
登录页面中,一个post将用户信息(录入的用户名密码)进行提交。此时,如何将密码信息从页面中得到?...
登录页面中,一个post将用户信息(录入的用户名密码)进行提交。此时,如何将密码信息从页面中得到?
展开
2个回答
展开全部
1、判断部分
<script language="javascript">
<!--
function isok(theform)
{
if (theform.user_name.value.length<2 || theform.user_name.value.length>10)
{
alert("学生姓名请填写真实姓名!");
theform.user_name.focus();
return (false);
}
if (theform.password.value.length<3 || theform.password.value.length>10)
{
alert("密码最少要3位,最多10位! !");
theform.password.focus();
return (false);
}
if (theform.password_two.value=="")
{
alert("你还有确认密码没填呢!");
theform.password_two.focus();
return (false);
}
if (theform.password_two.value!=theform.password.value)
{
alert("两次密码怎么不一样!");
theform.password_two.focus();
return (false);
}
if (theform.userclass.value=="")
{
alert("你所在的专业班级还没填呢!");
theform.userclass.focus();
return (false);
}
if (theform.num.value=="")
{
alert("你的学生证号还没填呢!");
theform.num.focus();
return (false);
}
return (true);
}
-->
</script>
2、接受数据的表单部分
<form name="form1" method="post" action="userregcheck.asp" onSubmit="return isok(this)">
<input name="user_name" type="text" id="user_name" title="请输入您的姓名" size="15">
</label></td>
</tr>
<tr>
<td><div align="center">登陆密码:</div></td>
<td><input name="password" type="password" id="password" title="请输入您的密码" size="15"></td>
</tr>
<tr>
<td><div align="center">重输密码:</div></td>
<td><input name="password_two" type="password" id="password_two" size="15"></td>
</tr>
<tr>
<td><div align="center">专业班级:</div></td>
<td><label>
<input name="userclass" type="text" id="userclass" size="15">
</label></td>
</tr>
<tr>
<td><div align="center">学生证号:</div></td>
<td><label>
<input name="num" type="text" id="num" size="15">
</label></td>
</tr>
</table>
<center>
<p><br />
<input type="submit" name="submit" value="确认提交" />
<input type="reset" name="reset" value="重新输入" />
<input type="button" name="button" value="返回首页" onClick=" history.back()" />
</p>
</center>
</form>
3、数据验证保存到数据库部分
<!--#include file="conn.asp"-->
<%
user_name =left(request("user_name"),15)
password =left(request("password"),15)
userclass =left(request("userclass"),15)
num =left(request("num"),15)
if password="" then
response.write "数据有错!"
response.end
end if
Set rs = Server.CreateObject("adodb.recordset")
sql="select * from user where username like '" & user_name & "'"
rs.open sql,conn,1,3
if rs.eof and rs.bof then
rs.addnew
rs("username")=user_name
rs("userpwd")=password
rs("userclass")=userclass
rs("usernum")=num
rs.update
rs.movelast
session("user_id")=rs("userid")
session("name")=rs("username")
set rs2=server.createobject("adodb.recordset")
sql="select* from user where username='" &session("name") & "' "
rs2.open sql,conn,1,3
rs2("onlinetime")=now
rs2("userip")=Request.serverVariables("REMOTE_ADDR")
rs2.update
session("userip") = rs2("userip")
rs.close
response.redirect "index1.asp"
response.end
else
%>
<a href="userreg.asp">[重新注册]</a>
<%end if%>
有问题可以直接联系我啊
<script language="javascript">
<!--
function isok(theform)
{
if (theform.user_name.value.length<2 || theform.user_name.value.length>10)
{
alert("学生姓名请填写真实姓名!");
theform.user_name.focus();
return (false);
}
if (theform.password.value.length<3 || theform.password.value.length>10)
{
alert("密码最少要3位,最多10位! !");
theform.password.focus();
return (false);
}
if (theform.password_two.value=="")
{
alert("你还有确认密码没填呢!");
theform.password_two.focus();
return (false);
}
if (theform.password_two.value!=theform.password.value)
{
alert("两次密码怎么不一样!");
theform.password_two.focus();
return (false);
}
if (theform.userclass.value=="")
{
alert("你所在的专业班级还没填呢!");
theform.userclass.focus();
return (false);
}
if (theform.num.value=="")
{
alert("你的学生证号还没填呢!");
theform.num.focus();
return (false);
}
return (true);
}
-->
</script>
2、接受数据的表单部分
<form name="form1" method="post" action="userregcheck.asp" onSubmit="return isok(this)">
<input name="user_name" type="text" id="user_name" title="请输入您的姓名" size="15">
</label></td>
</tr>
<tr>
<td><div align="center">登陆密码:</div></td>
<td><input name="password" type="password" id="password" title="请输入您的密码" size="15"></td>
</tr>
<tr>
<td><div align="center">重输密码:</div></td>
<td><input name="password_two" type="password" id="password_two" size="15"></td>
</tr>
<tr>
<td><div align="center">专业班级:</div></td>
<td><label>
<input name="userclass" type="text" id="userclass" size="15">
</label></td>
</tr>
<tr>
<td><div align="center">学生证号:</div></td>
<td><label>
<input name="num" type="text" id="num" size="15">
</label></td>
</tr>
</table>
<center>
<p><br />
<input type="submit" name="submit" value="确认提交" />
<input type="reset" name="reset" value="重新输入" />
<input type="button" name="button" value="返回首页" onClick=" history.back()" />
</p>
</center>
</form>
3、数据验证保存到数据库部分
<!--#include file="conn.asp"-->
<%
user_name =left(request("user_name"),15)
password =left(request("password"),15)
userclass =left(request("userclass"),15)
num =left(request("num"),15)
if password="" then
response.write "数据有错!"
response.end
end if
Set rs = Server.CreateObject("adodb.recordset")
sql="select * from user where username like '" & user_name & "'"
rs.open sql,conn,1,3
if rs.eof and rs.bof then
rs.addnew
rs("username")=user_name
rs("userpwd")=password
rs("userclass")=userclass
rs("usernum")=num
rs.update
rs.movelast
session("user_id")=rs("userid")
session("name")=rs("username")
set rs2=server.createobject("adodb.recordset")
sql="select* from user where username='" &session("name") & "' "
rs2.open sql,conn,1,3
rs2("onlinetime")=now
rs2("userip")=Request.serverVariables("REMOTE_ADDR")
rs2.update
session("userip") = rs2("userip")
rs.close
response.redirect "index1.asp"
response.end
else
%>
<a href="userreg.asp">[重新注册]</a>
<%end if%>
有问题可以直接联系我啊
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询