验证用户名是否存在的问题。

jim_cn 2005-09-01 04:32:17
一个改名的代码,本来没有做新用户名是否存在的判定,请问如何做此判定?
原代码如下:
<%
dim action,rs,newname,old,username,sql
action=oblog.filt_badstr(request("action"))
newname=oblog.filt_badstr(trim(request("newname")))
old=trim(request("old"))
if action="DoUpdate" then
If newname="" Then
Response.Write("<script language=javascript>alert('新用户名不能为空!');history.back();</script>")
Response.End()
End If
If old="" Then
Response.Write("<script language=javascript>alert('原用户名不能为空!');history.back();</script>")
Response.End()
End If
oblog.execute("update [oblog_user] set username='"&newname&"' where username='"&old&"'")
oblog.execute("update [oblog_log] set author='"&newname&"' where author='"&old&"'")
oblog.execute("update [oblog_comment] set comment_user='"&newname&"' where isguest=0 and comment_user='"&old&"'")
oblog.execute("update [oblog_message] set message_user='"&newname&"' where isguest=0 and message_user='"&old&"'")
oblog.execute("update [oblog_pm] set sender='"&newname&"' where sender='"&old&"'")
oblog.execute("update [oblog_pm] set incept='"&newname&"' where incept='"&old&"'")
response.Write("<br>已经成功将用户名进行了更改!")
else
%>
如何在其中增加目标用户名也就是newname是否存在的判定?如果存在的话返回错误提示。
...全文
78 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
madpolice 2005-09-01
  • 打赏
  • 举报
回复
if old=newname then
response.write "新旧相同"
response.end
end if

if not conn.execute("select top 1 username from tb where username='" & newname & "'").EOF then
response.write "新名已经存在"
response.end
end if
jim_cn 2005-09-01
  • 打赏
  • 举报
回复
我晕,人都哪里去了。。不是很难实现吧,可惜我不会,就没人来帮我吗
jim_cn 2005-09-01
  • 打赏
  • 举报
回复
怎么都这么冷漠现在,没人帮忙了吗
jim_cn 2005-09-01
  • 打赏
  • 举报
回复
还有就是如何增加判定old是否存在的问题,现在改名的话,如果原用户名不存在也提示修改成功,如何增加判定,如果原来的用户名不存在返回错误。
请赐教。

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧