jarv Posted March 19, 2009 Share Posted March 19, 2009 is this right? IF $_SESSION['email']='true'{ header( "Location: thankyou.htm?source=Emailer1&campaignname1=MMO2574&contact=contact" ); } else { header( "Location: thankyou.htm?contact=contact" ); } Quote Link to comment https://forums.phpfreaks.com/topic/150137-if-else-statement/ Share on other sites More sharing options...
rhodesa Posted March 19, 2009 Share Posted March 19, 2009 well...to get rid of the syntax errors: if ($_SESSION['email'] == 'true') { header( "Location: thankyou.htm?source=Emailer1&campaignname1=MMO2574&contact=contact" ); } else { header( "Location: thankyou.htm?contact=contact" ); } but what are you trying to accomplish? the above tests to see if the value of $_SESSION['email'] is equal to the string 'true'. are you just trying to see if $_SESSION['email'] has something in it? if so, i would use: if (isset($_SESSION['email']) && strlen($_SESSION['email'])) { header( "Location: thankyou.htm?source=Emailer1&campaignname1=MMO2574&contact=contact" ); } else { header( "Location: thankyou.htm?contact=contact" ); } Quote Link to comment https://forums.phpfreaks.com/topic/150137-if-else-statement/#findComment-788423 Share on other sites More sharing options...
jarv Posted March 19, 2009 Author Share Posted March 19, 2009 thanks, I'm setting a session in another page as below: <?php // this starts the session session_start(); // this sets variables in the session $_SESSION['email']='true'; ?> in my form i want to say something like: IF Session == true then go to a URL IF not the go elsewhere! Quote Link to comment https://forums.phpfreaks.com/topic/150137-if-else-statement/#findComment-788443 Share on other sites More sharing options...
rhodesa Posted March 19, 2009 Share Posted March 19, 2009 then this one should work fine: if ($_SESSION['email'] == 'true') { header( "Location: thankyou.htm?source=Emailer1&campaignname1=MMO2574&contact=contact" ); } else { header( "Location: thankyou.htm?contact=contact" ); } Quote Link to comment https://forums.phpfreaks.com/topic/150137-if-else-statement/#findComment-788447 Share on other sites More sharing options...
jarv Posted March 19, 2009 Author Share Posted March 19, 2009 thanks, whatever I do it always goes to: thankyou.htm?contact=contact am i setting my session properly? <?php // this starts the session session_start(); // this sets variables in the session $_SESSION['email']='true'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/150137-if-else-statement/#findComment-788455 Share on other sites More sharing options...
Maq Posted March 19, 2009 Share Posted March 19, 2009 That should work. You have session_start at the top of that page, correct? Quote Link to comment https://forums.phpfreaks.com/topic/150137-if-else-statement/#findComment-788468 Share on other sites More sharing options...
jarv Posted March 19, 2009 Author Share Posted March 19, 2009 yes, on my index.php I have: <?php // this starts the session session_start(); // this sets variables in the session $_SESSION['email']='true'; ?> and on the other page within the site containing the form submission: if ($_SESSION['email'] == 'true') { header( "Location: thankyou.htm?source=Emailer1&campaignname1=MMO2574&contact=contact" ); } else { header( "Location: thankyou.htm?contact=contact" ); } so I go to the index.php the click through to the form, fill out the form and I always end up at: thankyou.htm?contact=contact Quote Link to comment https://forums.phpfreaks.com/topic/150137-if-else-statement/#findComment-788471 Share on other sites More sharing options...
rhodesa Posted March 19, 2009 Share Posted March 19, 2009 try this: session_start(); if ($_SESSION['email'] == 'true') { header( "Location: thankyou.htm?source=Emailer1&campaignname1=MMO2574&contact=contact" ); } else { print "Something is wrong:<pre>"; print_r($_SESSION); exit; // header( "Location: thankyou.htm?contact=contact" ); } p.s. - you need session_start() on both pages Quote Link to comment https://forums.phpfreaks.com/topic/150137-if-else-statement/#findComment-788472 Share on other sites More sharing options...
jarv Posted March 19, 2009 Author Share Posted March 19, 2009 thank, I needed the session start in each page! Quote Link to comment https://forums.phpfreaks.com/topic/150137-if-else-statement/#findComment-788533 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.