?? student_modifyinfo.asp
字號:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%option explicit%>
<!--#include file="inc/conn.asp"-->
<!--#include file="inc/function.asp"-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>修改考生信息</title>
<link href="student.css" rel="stylesheet" type="text/css">
</head>
<body>
<%
'根據不同的參數值決定是修改考生提交的信息還是顯示考生信息修改頁面
if checkStudentLogin() = true then
if request.form("action") = "modify" then
call modifyInfo()
else
call showModifyInfo()
end if
else
response.redirect "student_login.asp"
end if
'顯示修改考生信息頁面
sub showModifyInfo()
dim rsInfo,strSqlInfo
set rsInfo = server.createobject("ADODB.Recordset")
strSqlInfo = "select * from student where username='" & request.cookies("aoyi")("username") & "'"
rsInfo.open strSqlInfo,G_CONN,1,1
if rsInfo.bof or rsInfo.eof then
rsInfo.close
set rsInfo = nothing
response.redirect "/student_login.asp"
end if
%>
<form action="/student_modifyinfo.asp" method="post">
<input name="action" type="hidden" value="modify">
<table align="center" width="90%" cellspacing="1" cellpadding="0" bgcolor="#FFFFFF" class="tborder">
<tr class="tdtbg">
<td colspan="3" align="center">
<font color="#FFFFFF"><strong> 修 改 信 息 </strong></font>
</td>
</tr>
<tr class="tdbg">
<td align="right">
登錄名稱:
</td>
<td>
<%=rsInfo("username")%>
</td>
</tr>
<tr class="tdbg">
<td align="right">
真實姓名:
</td>
<td>
<input name="studentname" class="text" type="text" size="18" maxlength="25" value="<%=rsInfo("studentname")%>">
</td>
</tr>
<tr class="tdbg">
<td align="right">
性別:
</td>
<td>
<input name="sex" type="radio" value="1"
<%
if rsInfo("sex") = true then
response.write "checked"
end if
%>
> 男
<input name="sex" type="radio" value="0"
<%
if rsInfo("sex") = false then
response.write "checked"
end if
%>
> 女
</td>
</tr>
<tr class="tdbg">
<td align="right">
出生日期:
</td>
<td>
<input name="birthday" class="text" type="text" size="14" maxlength="20" value="<%=FormatDatetime(rsInfo("birthday"),2)%>">
</td>
</tr>
<tr class="tdbg">
<td align="right">
E-mail地址:
</td>
<td>
<input name="email" class="text" type="text" size="20" maxlength="128" value="<%=rsInfo("email")%>">
</td>
</tr>
<tr class="tdbg">
<td align="right">
電話號碼:
</td>
<td>
<input name="tel" class="text" type="text" size="20" maxlength="50" value="<%=rsInfo("tel")%>">
</td>
</tr>
<tr class="tdbg">
<td colspan="2" height="30" align="center">
<input type="submit" value=" 修 改 ">
<input type="reset" value=" 復 原 ">
</td>
</tr>
</table>
</form>
<%
rsInfo.close
set rsInfo = nothing
end sub
'修改考生信息
sub modifyInfo()
dim rsModifyInfo,strSqlModifyInfo,strStudentName,blnSex,strTel,strEmail,dteBirthday,strErr
strErr = ""
'驗證考生提交的信息是否合法
if trim(request.form("studentname")) = "" then
strErr = strErr & "<li>真實姓名為空。</li>" & vbcrlf
else
strStudentName = trim(request.form("studentname"))
end if
if IsDate(trim(request.form("birthday"))) = false then
strErr = strErr & "<li>出生日期未填寫或格式不正確。</li>" & vbcrlf
else
dteBirthday = CDate(trim(request.form("birthday")))
end if
if CInt(request.form("sex")) > 0 then
blnSex = true
else
blnSex = false
end if
strEmail = trim(request.form("email"))
strTel = trim(request.form("tel"))
if strErr = "" then
'如果通過驗證則進行考生信息的修改并顯示成功信息
set rsModifyInfo = server.createobject("ADODB.Recordset")
strSqlModifyInfo = "select * from student where username='" & request.cookies("aoyi")("username") & "'"
rsModifyInfo.open strSqlModifyInfo,G_CONN,1,3
'驗證考生記錄是否存在
if rsModifyInfo.bof or rsModifyInfo.eof then
rsModifyInfo.close
set rsModifyInfo = nothing
response.redirect "/student_login.asp"
end if
'修改考生信息
rsModifyInfo("studentname") = strStudentName
rsModifyInfo("sex") = blnSex
rsModifyInfo("birthday") = dteBirthday
rsModifyInfo("email") = strEmail
rsModifyInfo("tel") = strTel
rsModifyInfo.update
rsModifyInfo.close
set rsModifyInfo = nothing
%>
<table width="90%" align="center" cellspacing="1" cellpadding="0" bgcolor="#FFFFFF" class="tborder">
<tr class="tdtbg">
<td align="center">
<font color="#FFFFFF"><strong> 修 改 信 息 </strong></font>
</td>
</tr>
<tr class="tdbg">
<td align="center">
考生 <%=request.cookies("studentname")%> 的信息已經成功修改!<br>
<a href="/index.asp" target="_top">返回首頁</a>
</td>
</tr>
</table>
<%
else '沒有通過驗證則顯示錯誤信息
showErrMsg(strErr)
end if
end sub
%>
</body>
</html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -