Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Banned
    Join Date
    Mar 2007
    Posts
    1,523
    Thanks
    116
    Thanked 0 Times in 0 Posts

    Question IF ELSE statement

    is this right?

    Code:
    IF $_SESSION['email']='true'{
     header( "Location: thankyou.htm?source=Emailer1&campaignname1=MMO2574&contact=contact" );
     } else {
     header( "Location: thankyou.htm?contact=contact" );
     }

  • #2
    New Coder
    Join Date
    Mar 2009
    Location
    Chicago, IL
    Posts
    69
    Thanks
    0
    Thanked 15 Times in 15 Posts
    You forgot parenthesis around if expression, and it has to be == to test equality:

    PHP Code:
    if ($_SESSION['email'] == 'true') { 

  • #3
    Regular Coder sea4me's Avatar
    Join Date
    Jan 2009
    Location
    Damn, I don't know...
    Posts
    390
    Thanks
    11
    Thanked 28 Times in 27 Posts
    Try:
    PHP Code:
    if ($_SESSION['email'] == 'true') { 
    header"Location: thankyou.htm?source=Emailer1&campaignname1=MMO2574&contact=contact" );
    }
    else {
    header"Location: thankyou.htm?contact=contact" );


  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Eh?
    PHP Code:
    if (isset($_SESSION['email']) && $_SESSION['email']) // Always check for isset!
    {
        
    header"Location: thankyou.htm?source=Emailer1&campaignname1=MMO2574&contact=contact" );
    }
    else
    {
       
    header"Location: thankyou.htm?contact=contact" );

    Technically the 'true' check could be false. Boolean true !== 'true', so I'd just use the shortcut check for && $_SESSION['email'] instead. This of course only works if the $_SESSION['email'] is actually set to true and not to something else, though a non-empty string is also true.
    What a pain these weak languages are >.<
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #5
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by steelaz View Post
    You forgot parenthesis around if expression, and it has to be == to test equality:

    PHP Code:
    if ($_SESSION['email'] == 'true') { 

    Hello,


    This is the right code, add parenthesis then it will work.

    Regards,
    sarah_9
    Last edited by vinyl-junkie; 03-20-2009 at 01:04 PM. Reason: Signatures may only be added from the Profile feature.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •