php - 点击提交按钮后重定向到下一页 php mysql

标签 php mysql redirect

我想在点击提交页面后重定向到下一页,但出现以下错误:

Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\forms\P_details.php:80) in C:\xampp\htdocs\P_details.php on line 70

以下是P_details.php上的php代码

//connect to connect to the database and initialize all functions
include 'scripts/functions/init.php';
include 'html/head.php';
include 'html/page_title.php';
include 'html/top_menu.php';
include 'titles/P_details.php';

//Generate a random Personid
$Personid = rand(1,9999999);
$_SESSION['Personid'] = $Personid;
//Carry over the Jobid to this page
$Jobid = $_SESSION['SESS_MEMBER_JOB'];

if(empty($_POST)=== false)
    {
        $R_fields = array('Title','Surname','Forename','IdentityNumber','Gender','Race','Nationality');
        foreach($_POST as $key=>$value)
        {
            if (empty($value) && in_array($key,$R_fields)=== true)
                {
                    $errors[] = 'fields marked with (*) are required';
                    break 1;
                }
        }

        if(empty($errors)=== true)
            {

                if($_POST['title'] == '-Select-')
                    {
                        $errors[] ='Please select Title';
                    }
                if($_POST['Gender'] == '-Select-')
                    {
                        $errors[] ='Please select Gender';
                    }
                if($_POST['Race'] == '-Select-')
                    {
                        $errors[] ='Please select Race';
                    }
                if($_POST['Nationality'] == '-Select-')
                    {
                        $errors[] ='Please select Nationality';
                    }

            }

    }

    include 'forms/P_details.php';

    if(empty($_POST) === false && empty($errors)=== true)
        {
            //submit personal details
            $personal_details = array(
            'Personid'=>$Personid,
            'Title' => $_POST['title'],
            'Surname'=>$_POST['Surname'],
            'Forename' => $_POST['Forename'],
            'IdentityNumber'=>$_POST['IdentityNumber'],                                             
            'Gender'=>$_POST['Gender'],
            'Race'=>$_POST['Race'],
            'Nationality'=>$_POST['Nationality'],
            'WorkPermitNumber'=>$_POST['WorkPermitNumber'],
            'JobID'=>$Jobid);                       
            personal_details($personal_details);                        
            //redirect
            header('Location:Address_insert.php');
            exit();                                                                                                                             
        }
    else if(empty($errors) === false)
        {
            //output errors if the errors array is not empty
            echo output($errors);
        }

?>

请帮忙

最佳答案

要么在页面顶部调用 ob_start() ,在底部调用 ob_end_flush() ,或者在 header( )

关于php - 点击提交按钮后重定向到下一页 php mysql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14811148/

相关文章:

php - 如何在按钮单击时添加带有 mysql 表数据的下拉列表?

.net - 将@(at 符号)-变量传递给 MySQL

mysql二进制日志,为每个命令指定数据库

php分页不显示sql数据

ASP.NET customErrors with mode=remoteOnly 和 global.asax 处理异常

php - 帮助 Wordpress 站点自定义 'Featured Img Size' & 'Non-Featured'

php - 注册php文件

php - 如何使用 PHP 的 post 方法(Post/Redirect/Get)在表单提交后重定向

我的 ASCX 控件上的 Javascript 没有将我重定向到新页面/控件

php - 搜索结果直接进入搜索结果页面