白素贞和小青法力:PHP和ASP的问题?最佳答案追加100分!

来源:百度文库 编辑:神马品牌网 时间:2024/04/27 18:27:50
以前在某论坛上看到一个“刷新一次变一次的贴图”,[IMG]http://www.xxx.com/xxx/xxx.php?img=02.jpg[/IMG]

查看那个“图片”的地址发现它是“xxx/xxx.php?img=02.jpg”这样的地址

很显然,这个所谓的“图片”实际上是一个PHP网页(带值为“02.jpg”的参数“img”)

我很好奇`这样贴图居然能成功……

由于不会PHP,我用ASP写了下面代码:

<%img=request.querystring("img")%>
<%if img="1.jpg" then response.write("<img src='http://localhost/image/logo.gif'></img>")%>

然后保存为1.asp

然后我又在另外一个网页中写入:

<img src="1.asp?img=1.jpg" />

结果发现贴图失败!!

请问高手```这个特效到底是怎么做成的???????????????????
——————————————
我找到个具体的例子``去看看吧

http://www.tianya.cn/new/TechForum/Content.asp?idItem=16&idArticle=569250

——————————————————————————————

request.querystring("img")
是获取上一个页面送过来的参数,但是你的<img src="1.asp?img=1.jpg" />并没有传递参数,因此request.querystring("img")就获取不到1.jpg这个字符串!!所以才不能显示你希望的图片!!

如果你希望可以变图片,下面是一段javascript的代码
<div id="Layer1" style="position:absolute; left:779px; top:0px; z-index:1">
<script type="text/javascript">
vNum = Math.random();
vNum = Math.round(vNum*8)+1;
vNum="<table border='0' cellpadding='0' cellspacing='0'><tr><td><img src = \../display/00" + vNum + ".jpg\ border='0'></td></tr></table>"
if (screen.height >= 768 && screen.width >= 1024) {
document.write(vNum);
}
</script>

left:779px; top:0px是控制图片出现的位置
vNum是图片的名字,是通过
vNum = Math.random();
vNum = Math.round(vNum*8)+1;
两行代码获得的随机数!
次处是1-9随机出现!

同样的原理,用ASP,用Rnd 函数获取一个随机数,用作图片名称,后面再加上.jpg的扩张名,就能刷行显示不通的图片了!

MyValue = Int((6 * Rnd) + 1)' 产生 1 到 6 之间的随机数

response.write("<img src=image/"&MyValue &".gif' />")

这样页面一刷新,MyValue 就会变,相应图片也就回变!

<%img=request.querystring("img")%>
<%
if img="1.jpg" then
response.write("http://localhost/image/logo.gif")
%>
这样就可以了。

如果你是做验证码的图片可以换种方式,先用PS做十个图片,然后命名为1.gif,2,gif....
然后这样
<%
session("safecodes")=""
Randomize
firstno=int(rnd*(9-0+1))+0
secondno=int(rnd*(9-0+1))+0
thirdno=int(rnd*(9-0+1))+0
fourthno=int(rnd*(9-0+1))+0
fivethno=int(rnd*(9-0+1))+0
response.Write("<img src=Images/"&firstno&".gif>")
response.Write("<img src=Images/"&secondno&".gif>")
response.Write("<img src=Images/"&thirdno&".gif>")
response.Write("<img src=Images/"&fourthno&".gif>")
response.Write("<img src=Images/"&fivethno&".gif>")
session("safecodes")=firstno&secondno&thirdno&fourthno&fivethno
%>

这是验证码最新编写方式!