tazdevil Posted January 28, 2008 Share Posted January 28, 2008 Hi All Please excuse my ignorance... I am a complete newbie to PHP and have a question. The following code does a check on a form for the form contents. What I want to do is add the following IF statement: IF post_town = LONDON put LONDON into the county textarea box as well I hope someone can help as I just can't figure this out. thanks <?php // address sanity checks $line1=ucwords(strtolower(substr(ereg_replace("[^A-Za-z0-9\. \-\,]", "", $line1),0,60))); $line2=ucwords(strtolower(substr(ereg_replace("[^A-Za-z0-9\. \-\,]", "", $line2),0,60))); $post_town=strtoupper(substr(ereg_replace("[^A-Za-z0-9\. \-\,]", "", $post_town),0,60)); $county=strtoupper(substr(ereg_replace("[^A-Za-z0-9\. \-\,]", "", $county),0,60)); $postcode=strtoupper(substr(ereg_replace("[^A-Z0-9 ]", "", strtoupper($postcode)),0,10)); $allok=1; if (strlen($line1)<2) { $allok=0;echo "<strong>Your street address is incorrect</strong><br />"; } if (strlen($post_town)<2) { $allok=0;echo "<strong>Your post town/city is incorrect</strong><br />"; } if (strlen($county)<2) { $allok=0;echo "<strong>Your county is incorrect</strong><br />"; } if ((strlen($postcode)<4) || (strlen($postcode)>10)) { $allok=0;echo "<strong>Your postcode is incorrect</strong><br />"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/88193-if-statement-question-from-newbie/ Share on other sites More sharing options...
nafetski Posted January 28, 2008 Share Posted January 28, 2008 <?php if($_POST['city']=="london") { echo "<textarea>" . $_POST['city'] . "</textarea>"; } ?> Edit, early morning havn't had my coffee =P Quote Link to comment https://forums.phpfreaks.com/topic/88193-if-statement-question-from-newbie/#findComment-451250 Share on other sites More sharing options...
revraz Posted January 28, 2008 Share Posted January 28, 2008 IF ($post_town = "LONDON"){ $county .= $post_town; } Something like that? Quote Link to comment https://forums.phpfreaks.com/topic/88193-if-statement-question-from-newbie/#findComment-451253 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.