BlackSmith Posted June 13, 2009 Share Posted June 13, 2009 <?php if(isset($_POST['Submit'])) { //Email information $to = "email@email.net"; $subject = "New Services Web Application"; $from = "email@anotheremail.net"; $headers = "From: $from"; //Email content from the signup.php form $regperiod = $_POST['regperiod']; $domain_name = $_POST['domain_name']; $topleveldomain = $_POST['topleveldomain']; $organization = $_POST['organization']; $id_number = $_POST['id_number']; $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $email = $_POST['email']; $contact_number = $_POST['contact_number']; $fax_number = $_POST['fax_number']; $address = $_POST['address']; $city = $_POST['city']; $postalcode = $_POST['postalcode']; $province = $_POST['province']; $other_province = $_POST['other_province']; $country = $_POST['country']; $password1 = $_POST['password1']; $password2 = $_POST['password2']; //Message content $message1 = "Good day, please assist in the processing of the following new application \n Registration period: $regperiod \n Domain name: www.$domain_name.$topleveldomain \n Organization: $organization \n Id Number: $id_number \n First Name: $first_name \n Last Name: $last_name \n Email Address: $email \n Contact Number: $contact_number \n Fax Number: $fax_number \n Address: $address \n City: $city \n Postal Code: $postalcode \n Province: $province \n Other Province: $other_province \n Country: $country \n Password: $password1 \n Confirn Password: $password2"; mail($to,$subject,$headers,$message1); echo "Mail Sent. Click <a href='index.php'>here</a> to return to home page"; } else { echo "Sorry there was a problem delivering your email please try again"; } //End of new applications script ?> I need some serious help with the validation of the script above - as you can see, the user's input is not being validated. Please assist with either PHP or JavaScript validation. I will post you a box of chocolates or Mint flavored gums... Quote Link to comment https://forums.phpfreaks.com/topic/162065-php-form-validation-help-needed/ Share on other sites More sharing options...
trq Posted June 14, 2009 Share Posted June 14, 2009 We are not here to write code for people. What exactly is your problem? Quote Link to comment https://forums.phpfreaks.com/topic/162065-php-form-validation-help-needed/#findComment-855299 Share on other sites More sharing options...
arimakidd Posted June 27, 2009 Share Posted June 27, 2009 In total (email info and email content) you have 22 variables I think. Not sure how many you need to validate but just use a for loop to iterate each element and perform whatever validation you need. First of course you need to put all your variables that require validation into a numerically indexed array. Then use the for loop to iterate through each item and perform whatever validation you require. The array would look something like this: $array = array("$to", "$subject", "$from" ....etc) Then use a for loop. The second expression which is evaluated should test against the number of items to be checked. So for example, if you have 5 items to validate then your for loop should look something like this: $item = 5; for($i =0; $i<=$item;$i++) { $array[$i]; //this is how to retrieve the item to be checked in the array. //perform validation here. } That should solve most if not all of your problems. Hope this helped. Quote Link to comment https://forums.phpfreaks.com/topic/162065-php-form-validation-help-needed/#findComment-864484 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.