如何添加一个功能?
这是原程序.记录到数据库ticket表的 xuehao里面是以a|b|c|....这样的
如何能让这个页面有个检查功能,当xuehao里面已经有了就不允许再添加了
就好象现在xuehao里面已经有a了,当在再次添加一次a的时候就会弹出alert框说你已经订票了
请各位帮帮忙
谢谢了
<!--#include file="conn.asp" -->
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>订票系统:订票</title>
</head>
<%
Function allto4(k)
if len(k)<4 then
for i=1 to 4-len(k)
allto4=allto4 & "0"
next
end if
allto4=allto4 & k
End Function
Set rs=Server.CreateObject("ADODB.RecordSet")
if Trim(Request.QueryString("action"))="" then
%>
<form name="book" method="POST" action="ticket_book.asp?action=add">
<select size="1" name="ticket" style="font-family: 宋体; font-size: 9pt">
<%
SQL="SELECT id,title,remainnum FROM ticket where remainnum>0 Order by id"
rs.Open SQL,Conn,1,1
if rs.bof and rs.eof then
%>
<option selected>暂时没有可订票的节目 !</option>
<%
else
do while not rs.eof
%>
<option value="<%=rs("id")%>"><%=rs("title") & " 票数:" & rs("remainnum")%></option>
<%
rs.movenext
loop
end if
rs.close
%>
</select>
<br><font style="font-family: 宋体; font-size: 9pt">你的姓名:</font><input type="text" name="student" size="20" style="font-family: 宋体; font-size: 9pt"><br>
<font style="font-family: 宋体; font-size: 9pt">你的学号:</font><input type="text" name="xuehao" size="20" style="font-family: 宋体; font-size: 9pt"><br>
<input style="font-family: 宋体; font-size: 9pt" type="submit" value="确定" name="B1" onClick="return check();">
<input style="font-family: 宋体; font-size: 9pt" type="reset" value="重填" name="B2">
</form>
<%
else
dim student,xuehao,ranNum,ticketnum
id=trim(Request.Form("ticket"))
student=trim(Request.Form("student"))
xuehao=trim(Request.Form("xuehao"))
Set rs=Server.CreateObject("ADODB.RecordSet")
SQL="SELECT id,title,number,remainnum,student,xuehao,ticketnum FROM ticket where id=" & int(id)
rs.Open SQL,Conn,1,3
ticketnum=id & allto4(rs("number") - rs("remainnum") + 1)
if rs("number")=rs("remainnum") then
rs("student")=student
rs("xuehao")=xuehao
rs("ticketnum")=ticketnum
else
rs("student")=rs("student") & "|" & student
rs("xuehao")=rs("xuehao") & "|" & xuehao
rs("ticketnum")=rs("ticketnum") & "|" & ticketnum
end if
rs("remainnum")=rs("remainnum")-1
rs.update
rs.close
set rs=nothing
response.Write "<script language=javascript>alert('成功!你的观众号是:" & ticketnum & ",须凭此号码取票,请务必记住!领票时间及地点请留意团学时空!');location.href='ticket_book.asp';</script>"
end if
%>
<script LANGUAGE="javascript">
function check()
{
function checkspace(checkstr) {
var str = '';
for(i = 0; i < checkstr.length; i++) {
str = str + ' ';
}
return (str == checkstr);
}
if(checkspace(document.book.student.value)) {
document.book.student.focus();
alert("请填写你的真实姓名!");
return false;
}
if(checkspace(document.book.xuehao.value)) {
document.book.xuehao.focus();
alert("请填写你的真实学号!");
return false;
}
}
</script>