PHP 重定向在 IE、Firefox 中不起作用 [英] PHP redirect not working in IE, Firefox after form

查看:39
本文介绍了PHP 重定向在 IE、Firefox 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试根据表单选择将用户重定向到不同的 URL.但该代码仅适用于 Chrome,不适用于 IE 或 FF.后者只是返回一个空白页.试用"变量是检查他们是否有资格继续

I am trying to redirect users to different URLs depending upon a form selection. But the code is only working in Chrome and not IE or FF. The latter just return a blank page. The 'trial' variable is to check if they are eligible to proceed

我的代码是:

<?php
    if ($_POST['trial'] == 'TRUE') {
    if ($_POST['submit1'] == 'x') { header('Location:http://www.url1.com'); }
    if ($_POST['submit2'] == 'y') { header('Location:http://www.url2.com'); }
    }  
if (!isset($_POST['trial'])) {
include 'error.php';}
?>

我看不出问题出在哪里?

I can't see where the problem lies?

有人可以帮忙吗?

谢谢TT

推荐答案

发送重定向后停止脚本.还要注意 Location: 之后的 SPACE.

Stop the script after sending redirection. Also mind the SPACE after Location:.

header ('Location: http://www.url1.com');
exit ();

这篇关于PHP 重定向在 IE、Firefox 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆