creasign Posted February 16, 2009 Share Posted February 16, 2009 hey firstly loving to stuff i am seeing here.. secondly i need some help... i am trying to write an if then statement here is what i have or the bit with the problem ! // What to send $email=mail($to,$subject,$message,$header); // What to do when done { if trim($_POST['age'] < 18 echo "please Download the parental consent form <a target="_blank" href="www.wokinghambikeathon.co.uk/documents/parentalconsentform.pdf">here</a><br>then click <a href="www.wokinghambikeathon.co.uk/register2.php">here</a> to continue"); else header("Location: http://www.wokinghambikeathon.co.uk/register2.php"); } else { echo "ERROR"; } what i am trying to do is that if a user trys to register for the event and they are under 18 it will show a message for them to download the parentral consent form then continue .. i get the error unexpected T_STRING on line 119 (i have marked this line with 3 *'s ) i have tried many different aproaches but i am stumped .. any sugestions? Quote Link to comment https://forums.phpfreaks.com/topic/145486-solved-ifthen-satement-whats-wrong/ Share on other sites More sharing options...
allworknoplay Posted February 16, 2009 Share Posted February 16, 2009 if (trim($_POST['age']) < 18) { echo "your statements here" }else{ header("Location: http://www.wokinghambikeathon.co.uk/register2.php"); } Quote Link to comment https://forums.phpfreaks.com/topic/145486-solved-ifthen-satement-whats-wrong/#findComment-763779 Share on other sites More sharing options...
samshel Posted February 16, 2009 Share Posted February 16, 2009 ur syntax is wrong... try this if trim($_POST['age'] < 18) { echo "please Download the parental consent form <a target="_blank" href="www.wokinghambikeathon.co.uk/documents/parentalconsentform.pdf">here</a><br>then click <a href="www.wokinghambikeathon.co.uk/register2.php">here</a> to continue"; } Quote Link to comment https://forums.phpfreaks.com/topic/145486-solved-ifthen-satement-whats-wrong/#findComment-763780 Share on other sites More sharing options...
creasign Posted February 17, 2009 Author Share Posted February 17, 2009 new error .. Parse error: syntax error, unexpected T_STRING, expecting '(' in /home/wokingba/public_html/send_register.php on line 117 *** if trim($_POST['age'] < 18); { echo "please Download the parental consent form <a target="_blank" href="www.wokinghambikeathon.co.uk/documents/parentalconsentform.pdf">here</a><br>then click <a href="www.wokinghambikeathon.co.uk/register2.php">here</a> to continue"; }else{ header("Location: http://www.wokinghambikeathon.co.uk/register2.php"); } thats what i have th *** marks the line the error is on .. its such a pain and i though i was half decent at php :-\ Quote Link to comment https://forums.phpfreaks.com/topic/145486-solved-ifthen-satement-whats-wrong/#findComment-763789 Share on other sites More sharing options...
gevans Posted February 17, 2009 Share Posted February 17, 2009 new error .. Parse error: syntax error, unexpected T_STRING, expecting '(' in /home/wokingba/public_html/send_register.php on line 117 *** if trim($_POST['age'] < 18); { echo "please Download the parental consent form <a target="_blank" href="www.wokinghambikeathon.co.uk/documents/parentalconsentform.pdf">here</a><br>then click <a href="www.wokinghambikeathon.co.uk/register2.php">here</a> to continue"; }else{ header("Location: http://www.wokinghambikeathon.co.uk/register2.php"); } thats what i have th *** marks the line the error is on .. its such a pain and i though i was half decent at php :-\ Really easy one to fix, just comparing it to samshel's solution would solve the problem; if trim($_POST['age'] < 18); { should be if (trim($_POST['age']) < 18) { Quote Link to comment https://forums.phpfreaks.com/topic/145486-solved-ifthen-satement-whats-wrong/#findComment-763793 Share on other sites More sharing options...
creasign Posted February 17, 2009 Author Share Posted February 17, 2009 another error .. this is getting on my teets Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/wokingba/public_html/send_register.php on line 118 if trim($_POST['age'] < 18); { *** echo "please Download the parental consent form <a target="_blank" href="www.wokinghambikeathon.co.uk/documents/parentalconsentform.pdf">here</a><br>then click <a href="www.wokinghambikeathon.co.uk/register2.php">here</a> to continue"; }else{ header("Location: http://www.wokinghambikeathon.co.uk/register2.php"); } this little line is causing soo much problem i have been stairing at it for days everything i have tried conducts a new error! Quote Link to comment https://forums.phpfreaks.com/topic/145486-solved-ifthen-satement-whats-wrong/#findComment-763916 Share on other sites More sharing options...
allworknoplay Posted February 17, 2009 Share Posted February 17, 2009 another error .. this is getting on my teets Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/wokingba/public_html/send_register.php on line 118 if trim($_POST['age'] < 18); { *** echo "please Download the parental consent form <a target="_blank" href="www.wokinghambikeathon.co.uk/documents/parentalconsentform.pdf">here</a><br>then click <a href="www.wokinghambikeathon.co.uk/register2.php">here</a> to continue"; }else{ header("Location: http://www.wokinghambikeathon.co.uk/register2.php"); } this little line is causing soo much problem i have been stairing at it for days everything i have tried conducts a new error! becuase you're not escaping the HTML tags in your echo... Do it like this... if trim($_POST['age'] < 18) { echo "please Download the parental consent form <a target=\"_blank\" href=\"www.wokinghambikeathon.co.uk/documents/parentalconsentform.pdf\">here</a><br>then click <a href=\"www.wokinghambikeathon.co.uk/register2.php\">here</a> to continue"; }else{ header("Location: http://www.wokinghambikeathon.co.uk/register2.php"); } Also you had a semi colon next to your conditional statement, don't do that so i took it out. Quote Link to comment https://forums.phpfreaks.com/topic/145486-solved-ifthen-satement-whats-wrong/#findComment-763921 Share on other sites More sharing options...
Philip Posted February 17, 2009 Share Posted February 17, 2009 if trim($_POST['age'] < 18) { echo "please Download the parental consent form <a target=\"_blank\" href=\"www.wokinghambikeathon.co.uk/documents/parentalconsentform.pdf\">here</a><br>then click <a href=\"www.wokinghambikeathon.co.uk/register2.php\">here</a> to continue"; }else{ header("Location: http://www.wokinghambikeathon.co.uk/register2.php"); } Also you had a semi colon next to your conditional statement, don't do that so i took it out. You're still missing something, namely in trim() // Technically, you won't need trim() if(trim($_POST['age']) < 18) { echo '{lease Download the parental consent form <a target="_blank" href="www.wokinghambikeathon.co.uk/documents/parentalconsentform.pdf">here</a><br>then click <a href="www.wokinghambikeathon.co.uk/register2.php">here</a> to continue'; // I find it easiest to use single quotes on echo and double quotes in my html. // it requires less escaping }else{ header("Location: http://www.wokinghambikeathon.co.uk/register2.php"); } Quote Link to comment https://forums.phpfreaks.com/topic/145486-solved-ifthen-satement-whats-wrong/#findComment-763923 Share on other sites More sharing options...
allworknoplay Posted February 17, 2009 Share Posted February 17, 2009 You're still missing something, namely in trim() Ahh you know why I missed that? because I had already fixed it earlier up in the thread!! The poster didn't fully copy my code earlier today.... Quote Link to comment https://forums.phpfreaks.com/topic/145486-solved-ifthen-satement-whats-wrong/#findComment-763930 Share on other sites More sharing options...
haku Posted February 17, 2009 Share Posted February 17, 2009 Show us your current code. Quote Link to comment https://forums.phpfreaks.com/topic/145486-solved-ifthen-satement-whats-wrong/#findComment-763933 Share on other sites More sharing options...
creasign Posted February 17, 2009 Author Share Posted February 17, 2009 <?php //set variables // code by creativity in design $name1 = trim($_POST['name1']); $name2 = trim($_POST['name2']); $sex = trim($_POST['sex']); $dob = trim($_POST['DOB']); $age = trim($_POST['age']); $email = trim($_POST['email']); $telephonenumber = trim($_POST['telephonenumber']); $etelephonenumber = trim($_POST['etelephonenumber']); $econtact = trim($_POST['econtact']); $streetname1 = trim($_POST['streetname1']); $streetname2 = trim($_POST['streetname2']); $town = trim($_POST['town']); $county = trim($_POST['county']); $postcode = trim($_POST['postcode']); $team = trim($_POST['team']); $charity = trim($_POST['charity']); $tshirt = trim($_POST['tshirt']); //message structure // Subject $subject = "$name1, $name2, $charity"; // Main message $message = "$name $name2 $sex $dob $age $email $telephonenumber emergency contact details - $etelephonenumber $econtact address - $streetname1 $streetname2 $town $county $postcode team - $team charity - $charity tshirt - $tshirt"; // Message header $header="from: $name1 $name2 <$email>"; // Customer email $to ='register@wokinghambikeathon.co.uk'; // What to send $email=mail($to,$subject,$message,$header); // What to do when done // Technically, you won't need trim() if(trim($_POST['age']) < 18) { echo '{lease Download the parental consent form <a target="_blank" href="www.wokinghambikeathon.co.uk/documents/parentalconsentform.pdf">here</a><br>then click <a href="www.wokinghambikeathon.co.uk/register2.php">here</a> to continue'; // I find it easiest to use single quotes on echo and double quotes in my html. // it requires less escaping }else{ header("Location: http://www.wokinghambikeathon.co.uk/register2.php"); ?> thats the whole page ... although now there is a new error Parse error: syntax error, unexpected $end in /home/wokingba/public_html/send_register.php on line 125 this is the last line of code so what you have chnaged already seems to have done the trick just something else there .. before i tried to add in this end bit the whole code worked fine and sent the emails ect .. so i realy dont know Quote Link to comment https://forums.phpfreaks.com/topic/145486-solved-ifthen-satement-whats-wrong/#findComment-764304 Share on other sites More sharing options...
Philip Posted February 17, 2009 Share Posted February 17, 2009 // Technically, you won't need trim() if(trim($_POST['age']) < 18) { echo '{lease Download the parental consent form <a target="_blank" href="www.wokinghambikeathon.co.uk/documents/parentalconsentform.pdf">here</a><br>then click <a href="www.wokinghambikeathon.co.uk/register2.php">here</a> to continue'; // I find it easiest to use single quotes on echo and double quotes in my html. // it requires less escaping }else{ header("Location: http://www.wokinghambikeathon.co.uk/register2.php"); ?> Should be: // Technically, you won't need trim() if(trim($_POST['age']) < 18) { echo 'Please Download the parental consent form <a target="_blank" href="www.wokinghambikeathon.co.uk/documents/parentalconsentform.pdf">here</a><br>then click <a href="www.wokinghambikeathon.co.uk/register2.php">here</a> to continue'; // I find it easiest to use single quotes on echo and double quotes in my html. // it requires less escaping }else{ header("Location: http://www.wokinghambikeathon.co.uk/register2.php"); } // you were missing this! ?> Edit: fixed typo with { instead of P Quote Link to comment https://forums.phpfreaks.com/topic/145486-solved-ifthen-satement-whats-wrong/#findComment-764309 Share on other sites More sharing options...
allworknoplay Posted February 17, 2009 Share Posted February 17, 2009 You're missing a closing bracket before the last line...it should be: // Technically, you won't need trim() if(trim($_POST['age']) < 18) { echo '{lease Download the parental consent form <a target="_blank" href="www.wokinghambikeathon.co.uk/documents/parentalconsentform.pdf">here</a><br>then click <a href="www.wokinghambikeathon.co.uk/register2.php">here</a> to continue'; // I find it easiest to use single quotes on echo and double quotes in my html. // it requires less escaping }else{ header("Location: http://www.wokinghambikeathon.co.uk/register2.php"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/145486-solved-ifthen-satement-whats-wrong/#findComment-764311 Share on other sites More sharing options...
creasign Posted February 17, 2009 Author Share Posted February 17, 2009 you farking legend .. thank-you sooo much! Quote Link to comment https://forums.phpfreaks.com/topic/145486-solved-ifthen-satement-whats-wrong/#findComment-764313 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.