Jump to content

Recommended Posts

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" );
}

Link to comment
https://forums.phpfreaks.com/topic/150137-if-else-statement/#findComment-788423
Share on other sites

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!

Link to comment
https://forums.phpfreaks.com/topic/150137-if-else-statement/#findComment-788443
Share on other sites

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

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/150137-if-else-statement/#findComment-788471
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/150137-if-else-statement/#findComment-788472
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.