【www.gdgbn.com--安卓教程】

<%
from_url=Request.servervariables("http_referer")
serv_url=Request.servervariables("http_host")

if instr(from_url,serv_url)<>0 and instr(from_url,"reg.asp")<>0 then
Response.write "正确!"
else
Response.write "非法提交!"
End if
%>


你写的
<%
if mid(From_url,8,len(Serv_url))<>Serv_url or instr(from_url,"reg.asp")=0 then
        Response.Write "<script>alert("参数提交错误!请勿修改链接!");this.location.href="index.asp";</script>"
        Response.End
End if
%>

看红色部分
我写的那个判断条件
1.  instr(from_url,serv_url)<>0   判断是否同一域名,当域名相同时,返回true
2.  instr(from_url,"reg.asp")<>0 判断是否从reg.asp提交过来,当是从reg.asp提交过来时,返回true
当1 和 2成立的时候, true and true=true  提交是正确的,否则就是非法提交了


你写的那个判断条件
1. mid(From_url,8,len(Serv_url))<>Serv_ur     判断是否同一域名,是同一个域名,返回false
2. instr(from_url,"reg.asp")=0                       判断是否从reg.asp提交过来,是从reg.asp提交过来, 返回false
当 1 成立 2成立时,
true or false=true
false or true=true
就是表示提交不正确
只有当1为false 而且 2为false时,才是正确提交



所以说,你写的代码没有错,逻辑上原理一样,只是你的代码非法提交的时候返回true,我的代码是正确提交的时候返回true

而这样写就是非法提交的时候返回true
if not(instr(from_url,serv_url)<>0 and instr(from_url,"reg.asp")<>0) then
Response.write "非法提交!"
End if

一开始不清楚楼主是否需要在正确提交的时候也要执行代码,所以就写成我原来的那种,如果只需要判断非法提交时才需要执行代码,用你写的代码就OK了,用OR

本文来源:http://www.gdgbn.com/shoujikaifa/12219/