我对此很陌生并且很享受'与学习新事物有关的一些挫折和长时间工作。无论如何!我想让我的PHP脚本执行以下操作:
A)查看页面底部的表格(在网站每个页面的页脚中)是否已使用隐藏输入触发。 B)打开数据库中的表并做一些事情。 C)根据结果,停止处理,忘记所有内容并转到两个新的php页面之一;要么感谢加入'或者'已经是会员'。
A和B正在精彩地工作,无论我做什么,C都拒绝工作。我尝试过使用标题("位置:http://www.xxx.co.uk/xxx.php"); 几乎在页面的每个部分,以及所有各种微妙的变化 - 单引号,双引号,位置后的空格等,我已经看到用于其他答案。
如果我在header()命令之后发出退出,那么它就会这样做,我只是得到一个完全白页而没有任何内容,如果我不退出,那么我刚刚打开的页面将保持不变。< / p>
我已经阅读了有关此主题的其他帖子,并且看到标题的复杂性与已经调用的标题有关,但我不理解答案,我没有看到错误,它只是不会重定向。
在尝试打开doctype声明之前,我已经尝试将所有php移动到页面顶部,但仍然没有骰子。
这可能与我的页面结构有关,如下所示:
每个php都以header.on开头,包含header.php,以footen.php的include_once结尾。在标题内部,我从一个php fuctions文件的include_once开始,然后是一些html,然后检查我的页脚表单是否被使用。
有人可以用简单的术语解释header()命令的限制,这样我就可以看到我是否能够使用它,或者我是否需要重新设计我的整个策略。
以下是一些代码:
其中一页:
<?
include_once ("includes/header.php");
?>
HTML distinct to page
<?
include_once ("includes/footer.php");
?>
标题文件:
<? include_once("includes/functions.php"); ?>
In here is just the logon script for the database and a global variable for the logon...
<?
if (isset($_POST['submitfoot'])) {
Code to send me an email to tell me what is happening...
/* log on to database */
openDB();
/*tidy fields and check for existing record */
$tidyemail = trim($_POST['footemail']);
$tidyname = trim($_POST['footname']);
$sql_email = "SELECT id FROM subscribers WHERE email = '".$tidyemail."'";
$check_res = mysqli_query($mysqli, $sql_email) or die(mysqli_error($mysqli));
if (mysqli_num_rows($check_res) < 1) {
/* free result add the new record */
mysqli_free_result($check_res);
$add_sql = "INSERT INTO subscribers (name,email,date,sub) VALUES('".$tidyname."','".$tidyemail."',CURDATE(),1)";
$add_res = mysqli_query($mysqli, $add_sql) or die(mysqli_error($mysqli));
/* redirect to thanks page */
header("Location: http://www.xxx.co.uk/thanks.php");
} else {
/* redirect to already subscribed page */
header("Location: http://www.xxx.co.uk/subalready.php");
}
}
?>
Then there is the rest of the HTML including js script headers, page header, page body with common menu system for all pages etc.
我意识到论坛上的代码很乱,但实际文件中的代码更加简洁,所以对任何困难都表示道歉。
提前感谢您提供任何可以阻止我对此问题感到茫然的指导。
编辑
谢谢showdev - 我现在按照你的建议启用了错误:我明白了:
警告:无法修改标题信息 - 已在/homepages/9/d302209163/htdocs/includes/header.php中发送的标题(输出于/homepages/9/d302209163/htdocs/includes/header.php:9开始)第59行
所以这是以前的问题面临的问题。任何人都可以轻轻地告诉我如何解决这个问题。
...谢谢
答案 0 :(得分:0)
你已经尝试过而不是使用:
header("Location: http://www.xxx.co.uk/thanks.php");
和
header("Location: http://www.xxx.co.uk/subalready.php");
尝试将其更改为:
header("Location:thanks.php");
和
header("Location:subalready.php");
我只是假设它们都包含在您的WWW文件夹中,您不再需要添加该网址。