想知道是否有人能帮忙。我的问题是,该网站在localhost上工作,但当我将其ftp到实时服务器时,header()不会将它们重定向到(在本例中)感谢页面,即数据库中记录的数据。
PHP代码:
<?php
if (isset($_POST['submit'])) {
$connect_error = 'Sorry, Connection problems.';
mysql_connect('localhost', 'user', 'password') or die($connect_error);
mysql_select_db('email_logs') or die($connect_error);
$sql = "INSERT INTO client_data (name, email) VALUES ('" . mysql_real_escape_string($_POST['name']) . "', '" . mysql_real_escape_string($_POST['email']) . "')";
mysql_query($sql);
mysql_close();
header("Location: thankyou.php");
exit();
}
?>
您的代码很好。。。如果你想,你可以尝试定义相对路径,比如。。。/path/to/thankyou.php
。。注意发生了什么。。如果它仍然没有运行。。然后通过error_reporting(E_ALL);ini_set('display_errors', 1);
进行检查,并告诉我们实际错误
这可能会对您有所帮助。
ob_start();
您可以将其添加到thankyou.php
的顶部
在脚本的顶部尝试
ob_start("ob_gzhandler");
尝试使用以下代码
fileName:fix.php
<?php
ob_start();
...
header('Location: page1.php');
...
ob_end_flush();
?>