现在如果我加载使用GET变量one
和two
会重定向的页面,但它之前它会显示这个PHP错误:Warning: Cannot modify header information - headers already sent by (output started at /home/site/public_html/lp-19.php:3) in /home/site/public_html/lp-19.php on line 5
头已经发出已
继承人我的代码:
<?php if(isset($_GET['one']) && isset($_GET['two'])) {?>
<?php
$value = "none";
setcookie("Disagree", $value, time()+30);
?>
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript' src='//redirect.com/script.js'></script>
</head>
<body>
set "Disagree" cookie and then redirect
</body>
</html>
<?php } else { ?>
<?php
$value = "agree";
setcookie("Yes", $value, time()+3000000);
?>
<!DOCTYPE html>
<html>
set "yes" cookie and display content if no "one" or "two" get variables in url
</html>
<?php }?>
我该如何摆脱这个错误,并根据哪个页面被加载来让php设置一个cookie?
这看起来很干净,但我需要JavaScript重定向而不是PHP ..我将如何使用该代码?这会花费时间在重定向之前加载html标签之间的内容,还是首先重定向? –
@JoeBobby这将立即重定向 - 为什么你需要JavaScript重定向? – Steve
因为它的外部脚本多数民众赞成从仪表板 –