Page 1 of 1

More then one Header Redirection

Posted: Fri Oct 09, 2009 1:00 pm
by nite4000
Hey I need to get this form code to work. I need it to redirect a user to a different page according to what they select in the drop box.
Here is the code

Code: Select all

$_SESSION['manual.php'] = true;
 
if (strlen($_POST['go'])) {
 
 
 if ($_POST['paypro'] == 'LR') 
 {
  
 
 $location = "lr_form.php";
 
 }
 
 if ($_POST['paypro'] == 'PM') 
  {
  
 
 $location = "pm_form.php";
 
 
 
 }
 
 
header ("Location: $location");
} else {
  $_SESSION['manual.php'] = false;
}
 
 
I am not sure why it wont work i get a error msgs about cannot send header information

hope someone can help

Thanks

Re: More then one Header Redirection

Posted: Fri Oct 09, 2009 1:13 pm
by jackpf
Is there any output before the error message?

Re: More then one Header Redirection

Posted: Fri Oct 09, 2009 1:31 pm
by nite4000
what kind of out put? I may not know it as a out put so you will have to give me an example

Re: More then one Header Redirection

Posted: Fri Oct 09, 2009 1:50 pm
by jackpf
As in, is there anything on the page before the error message??

Re: More then one Header Redirection

Posted: Fri Oct 09, 2009 2:02 pm
by nite4000
no only when i try to execute teh code after pressing the button

Re: More then one Header Redirection

Posted: Fri Oct 09, 2009 2:48 pm
by desperado
if there is there *any* whitespace, carriage return, html..... in your file before your script, you will get that error.

Code: Select all

<?php
$_SESSION['manual.php'] = true;
 
if (strlen($_POST['go'])) {
 
 
 if ($_POST['paypro'] == 'LR')
 {
 
 
 $location = "lr_form.php";
 
 }
 
 if ($_POST['paypro'] == 'PM')
  {
 
 
 $location = "pm_form.php";
 
 
 
 }
 
 
header ("Location: $location");
} else {
  $_SESSION['manual.php'] = false;
}
?>
the above would be ok, whereas below is not:

Code: Select all

 
<html>                [color=#80BF40]<--notice this?[/color]
<head>               [color=#80BF40]<--notice this?[/color]
                            [color=#80BF40]<--notice this?[/color]
<?php
$_SESSION['manual.php'] = true;
 
if (strlen($_POST['go'])) {
 
 
 if ($_POST['paypro'] == 'LR')
 {
 
 
 $location = "lr_form.php";
 
 }
 
 if ($_POST['paypro'] == 'PM')
  {
 
 
 $location = "pm_form.php";
 
 
 
 }
 
 
header ("Location: $location");
} else {
  $_SESSION['manual.php'] = false;
}
?>

Re: More then one Header Redirection

Posted: Fri Oct 09, 2009 3:05 pm
by nite4000
This is the error when i try it

Warning: Cannot modify header information - headers already sent by (output started at /home/surf/public_html/memheader.php:4) in /home/surf/public_html/members/manual.php on line 35


line 35 is this

Code: Select all

header ("Location: $location");
which is part of

Code: Select all

header ("Location: $location");
} else {
  $_SESSION['manual.php'] = false;
}
 

any ideas?

Re: More then one Header Redirection

Posted: Fri Oct 09, 2009 3:15 pm
by desperado
please re-read my previous post above. your script is probably an include within other files, therefore you have something before it is called.

Re: More then one Header Redirection

Posted: Fri Oct 09, 2009 3:19 pm
by nite4000
yeah i see what the problem is so there isnt no other way I can have it do what i want without using the header redirection?

Re: More then one Header Redirection

Posted: Fri Oct 09, 2009 3:23 pm
by desperado
why not just leave it by itself and have the form target "members/manual.php" directly, instead of the page where it is included?

the redirect will be instantanious, and you'll never notice you were on a page with no header and footer...