0

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

<?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. 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);
                        }
              ?>
2
  • 1
    what is the error you getting? Dec 14, 2012 at 15:38
  • I am not getting an error, it just doesnt redirect on a linux machine Dec 14, 2012 at 16:04

1 Answer 1

0

This is a complete shot in the dark, but might be right on. Windows is not case sensative, but NIX is.

Capture_Menu.php

Is that exactly how it is capitalized on your UNIX box?

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');
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.