所以我正在编写以下脚本,只是一个简单的'收集表单数据 - 将其弹出到数据库然后快乐的日子!由于某种原因,我只是得到一个空白页 - 尽管错误报告打开 - 它让我疯了! - 有任何想法吗?非常感谢您的帮助。
<?php
error_reporting(E_ALL & ~E_NOTICE);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
function isLoggedIn()
{
if(isset($_SESSION['valid']) && $_SESSION['valid'])
return true;
return false;
}
session_start();
//if the user has not logged in
if(!isLoggedIn())
{
header('Location: ../main');
die();
}
//! Checks if the user type is admin full
if ($_SESSION['type'] === 'admin-full')
{
$comp_name = $_POST['comp_name'];
$comp_number = $_POST['comp_number'];
$vat_number = $_POST['vat_number'];
$add1 = $_POST['add1'];
$add2 = $_POST['add2'];
$city = $_POST['city'];
$postcode = $_POST['postcode'];
$branch_name = $_POST['branch_name'];
$contact_name = $_POST['contact_name'];
$contact_number = $_POST['contact_number'];
//! Real_escape the form data
$comp_name = mysql_real_escape_string($comp_name);
$comp_number = mysql_real_escape_string($comp_number);
$vat_number = mysql_real_escape_string($vat_number);
$add1 = mysql_real_escape_string($add1);
$add2 = mysql_real_escape_string($add2);
$city = mysql_real_escape_string($city);
$postcode = mysql_real_escape_string($postcode);
$branch_name = mysql_real_escape_string($branch_name);
$contact_name = mysql_real_escape_string($contact_name);
$contact_number= mysql_real_escape_string($contact_number);
//! MySQL Query
require_once('../Connections/PropSuite.php');
mysql_select_db($database_PropSuite, $PropSuite);
$query = "INSERT INTO franchises
(comp_name, comp_number, vat_number, add1, add2, city, postcode, branch_name, contact_name, contact_number )
VALUES
('$comp_name', '$comp_number', '$vat_number', '$add1', '$add2', '$city', '$postcode', '$branch_name', '$contact_name', '$contact_number');";
mysql_query($query) or die(mysql_error());
mysql_close();
header(location:'franchise-new.php?success');
}
else {
echo('You need to be an admin user to do that!, If you are seeing this message in error, please contact the system administrator.');
}
?>
答案 0 :(得分:2)
成功完成MySQL命令后,您将拥有以下命令:
header(location:'franchise-new.php?success');
这应该完全引用。否则什么都不会加载,但你不会被重定向。
header('location: franchise-new.php?success');
答案 1 :(得分:0)
通常,Location头应使用绝对URI(即http://example.com/somewhere/main
)。否则你确定这个:
header('Location: ../main');
指向有效档案?在标题调用之后尝试添加echo语句以缩小您完成的代码分支。