truegilly Posted January 27, 2007 Share Posted January 27, 2007 Hi everybody :Dwas wondering if someone could help me with this one...i have a simple if statement and i would like PHP to automatically re-direct the page if it returns false.i have 2 php pages..[color=red]login.phplogin-process.php[/color]heres my code...[code]session_start();if ( (!isset($_POST['id'])) || (!isset($_POST['password'])) ){$problem = true;REDIRECT TO Login.php}[/code]any help will be much appreciatedthanks peopleTruegilly Quote Link to comment https://forums.phpfreaks.com/topic/35967-php-page-re-direct/ Share on other sites More sharing options...
DjNaF Posted January 27, 2007 Share Posted January 27, 2007 header("location: login.php"); Quote Link to comment https://forums.phpfreaks.com/topic/35967-php-page-re-direct/#findComment-170571 Share on other sites More sharing options...
jchemie Posted January 27, 2007 Share Posted January 27, 2007 [code]session_start();if ( (!isset($_POST['id'])) || (!isset($_POST['password'])) ){$problem = true;REDIRECT TO Login.php}[/code]Here what you can do is [code]session_start();if ( ($_POST['id']) || ($_POST['password'])){$problem = true;header("Location: login.php");}[/code]This should solve your problem.ThanksJyot Vakhariainfo@sitesmith.net.in Quote Link to comment https://forums.phpfreaks.com/topic/35967-php-page-re-direct/#findComment-170573 Share on other sites More sharing options...
truegilly Posted January 27, 2007 Author Share Posted January 27, 2007 thanks, ill have a play.Truegilly ;) Quote Link to comment https://forums.phpfreaks.com/topic/35967-php-page-re-direct/#findComment-170574 Share on other sites More sharing options...
truegilly Posted January 27, 2007 Author Share Posted January 27, 2007 hi,been having a play with the code you send but i keep getting this errorWarning: Cannot modify header information - headers already sent byany ideas ?? ??? Quote Link to comment https://forums.phpfreaks.com/topic/35967-php-page-re-direct/#findComment-170582 Share on other sites More sharing options...
cmgmyr Posted January 27, 2007 Share Posted January 27, 2007 you have to output the header redirect before you output any information. Do you have any sort of header include before your redirect line? Quote Link to comment https://forums.phpfreaks.com/topic/35967-php-page-re-direct/#findComment-170583 Share on other sites More sharing options...
truegilly Posted January 27, 2007 Author Share Posted January 27, 2007 no i dont,could you explain what i need to put at the top of the page ?? Quote Link to comment https://forums.phpfreaks.com/topic/35967-php-page-re-direct/#findComment-170586 Share on other sites More sharing options...
Orio Posted January 27, 2007 Share Posted January 27, 2007 http://www.phpfreaks.com/forums/index.php/topic,37442.0.htmlOrio. Quote Link to comment https://forums.phpfreaks.com/topic/35967-php-page-re-direct/#findComment-170591 Share on other sites More sharing options...
truegilly Posted January 27, 2007 Author Share Posted January 27, 2007 ok worked it out.its because i had an echo in the same page with the header("location: login-test.php");truegilly Quote Link to comment https://forums.phpfreaks.com/topic/35967-php-page-re-direct/#findComment-170595 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.