所以我正在编写此代码,以便您在第一个点击链接时转发到某个页面,或者如果您是在显示消息后将其发送回原始页面不是我做的初学者错误吗?
<?php
$count = file_get_contents('counter.txt');
$count = trim($count);
if ($count="0")
{
$count = $count + 1;
$fl = fopen("counter.txt","w+");
fwrite($fl,$count);
fclose($fl);
header("Location: newpage.html");
}
else
{
fclose($fl);
echo "Sorry but the item has already been sold out";
header("Location: oldpage.html");
}
?>
答案 0 :(得分:1)
至于延迟,你可以通过两种不同的方式完成它。第一种是使用PHP标头(就像你目前正在做的那样),但是把它改成这样:
<?php
header("refresh:5;url=oldpage.html");
echo "Sorry but the item has already been sold out";
?>
另一种方法是回显一段HTML代码,元刷新:
<?php
echo '<meta http-equiv="refresh" content="2;url=oldpage.html">';
echo "Sorry but the item has already been sold out";
?>
在两个示例中,5是刷新前的秒数。试验每一个,看看它是否符合您的需求。
答案 1 :(得分:0)
这可能是我不熟悉的某种语法,但我的脚本都没有
<? code
我只是使用
<?
此外,由于您没有延迟我们的标头标记,因此用户不会在其上方看到先前回显的语句。它会在页面有时间完全输出之前自动重定向。