验证用户名是否存在的问题。
一个改名的代码,本来没有做新用户名是否存在的判定,请问如何做此判定?
原代码如下:
<%
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是否存在的判定?如果存在的话返回错误提示。