简体   繁体   English

按下提交按钮php mysql后重定向到另一个页面

[英]Redirect to another page after pressing submit button php mysql

I would to redirect to the next page after the form is completed and the submit button is pressed. 填写完表格并按下“提交”按钮后,我将重定向到下一页。 This code works well on a windows server, but it fails to redirect to the next page on a linux server 该代码在Windows服务器上运行良好,但无法重定向到Linux服务器上的下一页

<?php
include 'scripts/functions/init.php';

Restrict();

?>
<?php


$userid = $_SESSION['userid'];
if (empty($_POST)=== false)
    {
        $R_fields = array('OFO_Code','OFO_Title','Curr_Code','Curr_Title');
        foreach($_POST as $key=>$value)
        {
            if (empty($value) && in_array($key,$R_fields)=== true)
                {
                    $errors[] = 'fields marked with (*) are required';
                    break 1;
                }
        }

        $_SESSION['Combo'] = $_SESSION['OFO_Code'].$_SESSION['Curr_Code'];      
        if(empty($errors)=== true)
            {
                if(Curr_Code_exists($_SESSION['Combo']))
                    {
                        $errors[] = 'Sorry, the Curriculum Code already exist, please use the edit function';
                    }
                if(strlen('Curr_Code')<6)
                    {
                        $errors[] ='Curriculum Code must be at least 6 Characters';
                    }

            }
    }

?>

the above code appears just before the html, followed by the form. 上面的代码出现在html之前,然后是表格。 then just after the submit button follows the following and it also lies within the within 然后紧随在提交按钮之后,以下内容也位于

<?php
                    $_SESSION['OFO_Code'] = $_POST['OFO_Code'];
                    $_SESSION['Curr_Code'] = $_POST['Curr_Code'];


                    if(empty($_POST) === false && empty($errors)=== true)
                        {
                            //Capture data from the fields to an array
                            $Capture_Occupation_info = array(
                            'OFO_Code' => $_SESSION['OFO_Code'],
                            'OFO_Title'=>$_POST['OFO_Title'],
                            'Curr_Code'=>$_SESSION['Combo'],
                            'Curr_Title'=>$_POST['Curr_Title'],
                            'userid'=>$userid);

                            //Submit the data into the database
                            capture_occupation_info($Capture_Occupation_info);
                            header('Location:Capture_Menu.php');
                            exit();
                        }
                    else
                        {
                            //Display errors

                            echo output($errors);
                        }
              ?>

This is a complete shot in the dark, but might be right on. 这是黑暗中的完整镜头,但可能正确。 Windows is not case sensative, but NIX is. Windows不区分大小写,但NIX区分大小写。

Capture_Menu.php Capture_Menu.php

Is that exactly how it is capitalized on your UNIX box? 这正是在UNIX机器上大写的方式吗?

Also, you can not display or echo to the browser before doing a header redirect. 此外,在执行标头重定向之前,您将无法显示或向浏览器回显。 Please check for echos or even lose blank spaces after things like ?> 请检查是否有回声,甚至在出现诸如?之后丢失空白

I have had redirections not work before because my code printed something to the output that I didn't do on purpose. 我以前进行过重定向不起作用,因为我的代码将某些内容打印到了我没有故意做的输出中。

You can try this... 你可以试试这个...

error_reporting(E_ALL); 
ini_set('display_errors', 'On');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM