更新信息的时后,我对一个文本框里的内容做了更改:
假如原信息:中国编程论坛
修改后的信息:[企业网站] ---中国编程论坛---
当我把"-"加上后更新就出了问题:显示所有信息就消失了
代码:
<!--#include file="conn.asp"-->
<%
'on error resume next
dim class_update
class_update=trim(request.querystring("class_update"))
if class_update="update" then
set updateid=server.createobject("adodb.recordset")
sql="select * from [links] where id="&trim(request.querystring("update_id"))
updateid.open sql,conn,1,3
%>
<form name="form0" method="post" action=?class_reupdate=update&update_reid=<%=updateid("id")%>>
<table width="800" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#224466">
<tr>
<td height="30" colspan="2" bgcolor="#336699"><div align="center" class="STYLE1">修改信息</div></td>
</tr>
<tr>
<td width="191" bgcolor="#FFFFFF"><div align="center">名称:</div></td>
<td width="606" height="30" bgcolor="#FFFFFF"> <input name="updatetitle" type="text" id="updatetitle" value="<%=updateid("usertitle")%>" size="30"></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"><div align="center">链接:</div></td>
<td height="30" bgcolor="#FFFFFF">
<input name="updateid" type="text" id="updateid" value="<%=updateid("userid")%>" size="30"></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"> </td>
<td height="30" bgcolor="#FFFFFF"><label>
<input name="submit_update" type="submit" id="submit_update" value="修改" />
</label></td>
</tr>
</table>
<br>
</form>
<%else%>
<form name="form1" method="post" action=?class_add=add>
<table width="800" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#224466">
<tr>
<td height="30" colspan="2" bgcolor="#336699"><div align="center" class="STYLE1">添加信息</div></td>
</tr>
<tr>
<td width="191" bgcolor="#FFFFFF"><div align="center">名称:</div></td>
<td width="606" height="30" bgcolor="#FFFFFF"> <input name="usertitle" type="text" id="usertitle" size="30"></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"><div align="center">链接:</div></td>
<td height="30" bgcolor="#FFFFFF">
<input name="userid" type="text" id="userid" size="30"></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"> </td>
<td height="30" bgcolor="#FFFFFF"><label>
<input type="submit" name="Submit" value="提交" />
</label></td>
</tr>
</table>
<br>
</form>
<%end if%>
<%
dim submit
submit=request.form("submit")
if submit="提交" then
dim class_add
class_add=trim(request.querystring("class_add"))
if class_add="add" then
dim usertitle,userid
usertitle=replace(trim(request.form("usertitle")),"'","")
userid=replace(trim(request.form("userid")),"'","")
if usertitle="" or userid="" then
response.write("<script>alert('名称跟链接不能为空!');</script>")
response.end()
end if
set class_rs=server.createobject("adodb.recordset")
sql="select * from [links] where usertitle='"&usertitle&"' or userid='"&userid&"'"
class_rs.open sql,conn,1,3
if class_rs.bof then
class_rs.addnew()
class_rs("usertitle")=usertitle
class_rs("userid")=userid
class_rs("usertype")=1
class_rs.update
response.write("<script>alert('信息添加成功!');location.href='sessice_index.asp';</script>")
response.end()
else
response.write("<script>alert('信息或链接有重复!');history.back(-1);</script>")
response.end()
end if
end if
end if
set rs=server.createobject("adodb.recordset")
sql="select * from [links] where usertype='1' order by id desc"
rs.open sql,conn,1,1
%>
<table width="800" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#336699">
<tr>
<td height="30" colspan="4" bgcolor="#336699"><div align="center" class="STYLE1">信息列表</div></td>
</tr>
<tr>
<td width="276" height="24" bgcolor="#FFFFFF"> 名称</td>
<td width="270" bgcolor="#FFFFFF"> 链接</td>
<td width="123" bgcolor="#FFFFFF"> 操作</td>
<td width="126" bgcolor="#FFFFFF"> 操作</td>
</tr>
<%do while not rs.eof%>
<tr>
<td height="20" bgcolor="#FFFFFF"> <%=rs("usertitle")%></td>
<td bgcolor="#FFFFFF"> <%=rs("userid")%></td>
<td bgcolor="#FFFFFF"><span class="STYLE3"> <a href="#" onClick="if (confirm('您真的要删除吗?\n\n注意:该操作不可恢复'))location.href='?class_del=del&del_id=<%=rs("id")%>'"><font color="#FF0000">删除</font></a></span></td>
<td bgcolor="#FFFFFF"><span class="STYLE4"> <a href=?class_update=update&update_id=<%=rs("id")%>><font color="#990000">修改</font></a></span></td>
</tr>
<%
rs.movenext
loop
%>
</table>
<p> </p>
</body>
</html>
<%
dim submit_update,class_reupdate,update_reid
submit_update=trim(request.form("submit_update"))
if submit_update="修改" then
class_reupdate=trim(request.querystring("class_reupdate"))
update_reid=trim(request.querystring("update_reid"))
if class_reupdate="update" then
dim updatetitle,updateid
updatetitle=replace(trim(request.form("updatetitle")),"'","")
updateid=replace(trim(request.form("updateid")),"'","")
set update_update=server.createobject("adodb.recordset")
sql="select * from [links] where id="&update_reid
update_update.open sql,conn,1,3
set re=server.createobject("adodb.recordset")
sql="select * from [links] where usertitle='"&updatetitle&"' and userid='"&updateid&"' and usertype='1' and id<>"&update_reid
re.open sql,conn,1,1
if re.bof then
if not update_update.bof then
update_update("usertitle")=trim(request.form("updatetitle"))
update_update("userid")=trim(request.form("updateid"))
update_update.update
response.write("<script>alert('信息修改成功!');location.href='sessice_index.asp';</script>")
response.end()
end if
else
response.write("<script>alert('信息有重复!');</script>")
response.end()
end if
end if
end if
%>
<%
dim class_del
class_del=trim(request.querystring("class_del"))
if class_del="del" then
set del_rs=server.createobject("adodb.recordset")
sql="delete * from [links] where id="&trim(request.querystring("del_id"))
del_rs.open sql,conn,1,3
response.write("<script>alert('删除成功!');location.href='sessice_index.asp';</script>")
response.end()
end if
rs.close
set rs=nothing
conn.close
set conn=nothing
%>