Code: Select all
<?php
if(isset($_POST['submit']))
{
$name = $_GET['name'];
$email = $_POST['email'];
$mobile = $_POST['mobile'];
$comments = $_POST['comments'];
if(empty($errors))
{
$to = "info@eventpromotion.ie";
$subject = "Event Promotion Enquiry!";
$body =
"First Name: " . $_POST['name'] .
"\nEmail: " . $_POST['email'] .
"\nMobile: " . $_POST['mobile'] .
"\nMessage: " . $_POST['comments'];
if (mail($to, $subject, $body)) {
echo("<p>Thanks for submitting your enquiry.</p>");
}
else
{
echo("<p>Message delivery failed.</p>");
}
}
else
{
echo "<p>".$error."</p>";
}
}
?>
<form id="form" method="post" action="testing.php">
<p>
<label>Name</label><br />
<input type="text" name="name" id="firstName" />
</p>
<p>
<label>Email:</label><br />
<input type="text" name="email" id="email" />
</p>
<p>
<label>Mobile:</label><br />
<input type="text" name="mobile" id="mobile" />
</p>
<p>
<label>Comments:</label> <br />
<textarea name="comments" cols="30" rows="3"></textarea>
</p>
<p> <input type="submit" name="submit" value="Submit" /></p>
</form> for name i want something like the input to be two words of a minimum of 3 charaters each maybe.. and if the user has not put this i want the script to display an error above the form saying something like "Please insert your full name with a space between your first and last name"
for the email field i would like a correctly formatted email address to be used and again if there is an error i would like the message to say something like "Please enter your correct email address"
For the phone field i would like the user to only enter a ten digit number
and for the comments maybe have a minimum of 20 chars..
Can somebody help me with this its bugging me all morning and i cant figure out the logic in it..
Thanks for your help...