MSUK1 Posted January 31, 2011 Share Posted January 31, 2011 hello, i am trying to create an addon to a registration form i made... the user fills in a field called "coup" and clicks submit [sends rest of data too..] if the coupon code is entered and it = the correct code, then ID=_STRING_ but if coupon code is not entered or it doesnt = the correct code tehn ID=_2NDSTRING_ i wrote this thinking it would work... $coup = $_POST['coup']; // coupon $couponVALID=46893213658NHJHCCC_KKL9665859; if (Trim($coup)=="DOSOM1") $couponVALID=46723ihqwiaNHJHCCC_KKL9665859; //inbetween this and successful print it connects to database and sends the data... //check if query successful if($result){ print "<meta http-equiv=\"refresh\" content=\"0;URL=index2.html?ID=$couponVALID\">"; } my problem is i get this.. Parse error: syntax error, unexpected T_STRING in /home2/erroll/public_html/send.php on line 29 now, i use for one form of validation: // validation $validationOK=true; if (Trim($fname)=="") $validationOK=false; if (Trim($lname)=="") $validationOK=false; if (Trim($add1)=="") $validationOK=false; if (Trim($city)=="") $validationOK=false; if (Trim($county)=="") $validationOK=false; if (Trim($country)=="") $validationOK=false; if (Trim($postcode)=="") $validationOK=false; if (Trim($email1)=="") $validationOK=false; if (Trim($email2)!=="$email1") $validationOK=false; if (Trim($mobile)=="") $validationOK=false; if (Trim($answer)!=="34") $validationOK=false; if (Trim($job)=="") $validationOK=false; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=index.html\">"; exit; } so i tried to follow similar steps to replicate this different validation type Link to comment https://forums.phpfreaks.com/topic/226179-if-code-then/ Share on other sites More sharing options...
kenrbnsn Posted January 31, 2011 Share Posted January 31, 2011 You're not enclosing your strings in quotes. This <?php $couponVALID=46893213658NHJHCCC_KKL9665859; if (Trim($coup)=="DOSOM1") $couponVALID=46723ihqwiaNHJHCCC_KKL9665859; ?> should be <?php $couponVALID='46893213658NHJHCCC_KKL9665859'; if (Trim($coup)=="DOSOM1") $couponVALID='46723ihqwiaNHJHCCC_KKL9665859'; ?> Ken Link to comment https://forums.phpfreaks.com/topic/226179-if-code-then/#findComment-1167599 Share on other sites More sharing options...
MSUK1 Posted January 31, 2011 Author Share Posted January 31, 2011 thank you how comes: // validation $validationOK=true; if (Trim($fname)=="") $validationOK=false; if (Trim($lname)=="") $validationOK=false; if (Trim($add1)=="") $validationOK=false; if (Trim($city)=="") $validationOK=false; if (Trim($county)=="") $validationOK=false; if (Trim($country)=="") $validationOK=false; if (Trim($postcode)=="") $validationOK=false; if (Trim($email1)=="") $validationOK=false; if (Trim($email2)!=="$email1") $validationOK=false; if (Trim($mobile)=="") $validationOK=false; if (Trim($answer)!=="34") $validationOK=false; if (Trim($job)=="") $validationOK=false; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=index.html\">"; exit; } doesnt use them? Link to comment https://forums.phpfreaks.com/topic/226179-if-code-then/#findComment-1167602 Share on other sites More sharing options...
kenrbnsn Posted January 31, 2011 Share Posted January 31, 2011 Because the string "false" is a built-in boolean not really a string. Ken Link to comment https://forums.phpfreaks.com/topic/226179-if-code-then/#findComment-1167610 Share on other sites More sharing options...
MSUK1 Posted January 31, 2011 Author Share Posted January 31, 2011 ah okay thank you also, just wondering, if the user directly went to index2.php how can i get it to redirect back if ID=blank or if ID doesnt even exist atm i have.. <?php if(isset($_GET['ID']) && $_GET['ID'] == ""){ print "<meta http-equiv=\"refresh\" content=\"0;URL=register.html\">"; } ?> just wondering what will do it for "...index2.php" Link to comment https://forums.phpfreaks.com/topic/226179-if-code-then/#findComment-1167617 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.