PHP issue

Discussion in 'PHP' started by dmi, Feb 25, 2008.

  1. #1
    Heya,

    I've got a little PHP issue. Below's the code...

    if(md5($verif_box).'a4xn' == $_COOKIE['tntcon']){
    	// if verification code was correct send the message and show this page
    	mail("mail@address.com", 'Name: '.$posName, 'IP Address: '.$_SERVER['REMOTE_ADDR']."\n\n"'Name: '.$posName."\n\n"'Docs: '.$posDocs."\n\n"'Address: '.$posAddress."\n\n"'Phone: '.$posPhone."\n\n"'Services: '.$posServices, "From: $posEmail");
    	// delete the cookie so it cannot sent again by refreshing this page
    	setcookie('tntcon','');
    } else {
    	// if verification code was incorrect then return to contact page and show error
    	header("Location:".$_SERVER['HTTP_REFERER']."?name=$posName&docs=$posDocs&address=$posAddress&phone=$posPhone&email=$posEmail&wrong_code=true");
    	exit;
    }
    PHP:
    What's wrong with it? It's not working. I guess that something's wrong with all the " and ' (or maybe not).

    Thanks in advance,
    dmi
     
    dmi, Feb 25, 2008 IP
  2. stoli

    stoli Peon

    Messages:
    69
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try:
    if(md5($verif_box).'a4xn' == $_COOKIE['tntcon']){
        // if verification code was correct send the message and show this page
        mail("mail@address.com", 'Name: '.$posName, 'IP Address: '.$_SERVER['REMOTE_ADDR']."\n\n".'Name: '.$posName."\n\n".'Docs: '.$posDocs."\n\n".'Address: '.$posAddress."\n\n".'Phone: '.$posPhone."\n\n".'Services: '.$posServices, "From: $posEmail");
        // delete the cookie so it cannot sent again by refreshing this page
        setcookie('tntcon','');
    } else {
        // if verification code was incorrect then return to contact page and show error
        header("Location:".$_SERVER['HTTP_REFERER']."?name=$posName&docs=$posDocs&address=$posAddress&phone=$posPhone&email=$posEmail&wrong_code=true");
        exit;
    }
    PHP:
     
    stoli, Feb 25, 2008 IP
  3. zerxer

    zerxer Peon

    Messages:
    368
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You should also place brackets around your variables if using them inside the double quotes or the other method.
    "{$var}"
    or
    "".$var.""
    PHP:
    It's good practice so you don't accidentally add characters onto a variable without wanting to.
     
    zerxer, Feb 25, 2008 IP