-1

因此,我正在编写以下脚本,只是对表单数据的“简单”收集-将其弹出到数据库中,然后快乐的日子!出于某种原因,我只是得到一个空白页——尽管打开了错误报告——它让我发疯!- 有任何想法吗?非常感谢您的帮助。

<?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.');
}


?>
4

2 回答 2

2

在你成功的 MySQL 命令结束时,你有这个命令:

header(location:'franchise-new.php?success');

这应该完全引用。否则不会加载任何内容,但您不会被重定向。

header('location: franchise-new.php?success');
于 2012-12-19T20:08:45.143 回答
0

通常 Location 标头应使用绝对 URI(即http://example.com/somewhere/main)。否则你确定这是:

header('Location: ../main');

指向有效文件?尝试在标题调用后添加 echo 语句以缩小您所在的代码分支。

于 2012-12-19T20:06:11.017 回答