Hi, I am having some difficulty sorting verification on my form.
I just want to include something that will not proccess the form unless all the fields are filled in.
At the minute it will still send even if the name etc is left out.
Any help greatly appreciated.
Code PHP:<?php if (isset($_POST['submit'])) { switch($_POST['contact_type']) { case 'Customer Services': $to = 'm1@gmail.com'; break; case 'K Ltd': $to = 'm1@gmail.com'; break; case 'K America': $to = 'm1@gmail.com'; break; case 'K Germany': $to = 'm1@gmail.com'; break; } $subject = "K SITE ENQUIRY"; $name_field = $_POST['name']; $email_field = $_POST['email']; $message = $_POST['message']; if (strlen(trim($message)) > 0) { $body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message"; if (mail($to, $subject, $body)) { echo "<h3>Thanks! Your email has been sent <br />We will answer your enquiry as soon as possible.</h3>"; } else { echo 'Cannot sent mail'; } } else { echo "<h3>Error! <br />Please ensure that all fields are filled out in order to email us!</h3>"; } } else { echo "blarg!"; } ?>
Code HTML4Strict:<form method="POST" action="mailer.php"> Your Name:<br /> <input type="text" name="name" size="24" /><br /> <br /> FAO:<br /> <select name="contact_type"> <option>Customer Services</option> <option>K Ltd</option> <option>K America</option> <option>K Germany</option> </select> <br /><br /> Your Email:<br /> <input type="text" name="email" size="24" /><br /> <br /> Your Message:<br /> <textarea rows="10" name="message" cols="55" /></textarea> <br /> <p>Please ensure that you have filled out all important information before submitting.</p> <input type="submit" value="Submit" name="submit" /> </form>
![]()






Bookmarks