Code: Select all
andCode: Select all
tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
OK what i am trying to do is setup a form that will make sure that people enter their email address and phone number in the proper format. How do i do this??? I have been searching and i am really new please help here is what i have so far. I also what it to say email address not valid and stop the form from processing, same with the phone, Thanks!!Code: Select all
//if (isset($_POST['submit'])) {
//process form
if (strlen($firstname) > 0) {
$firstname = stripslashes($firstname);
} else {
$firstname = NULL;
echo '<p><b><font color="red" size="2">You forgot to enter your first name.</font></b></p>';
}
//check for lastname
if (strlen($lastname) > 0) {
$lastname = stripslashes($lastname);
} else {
$lastname = NULL;
echo '<p><b><font color="red" size="2">You forgot to enter your last name.</font></b></p>';
}
//check for phonenumber
if (strlen($phonenumber) > 0) {
$phonenumber = stripslashes($phonenumber);
} else {
$phonenumber = NULL;
echo '<p><b><font color="red" size="2">You forgot to enter your phone number.</font></b></p>';
}
//check for email
if (strlen($email) > 0) {
$email = stripslashes($email);
} else {
$email = NULL;
echo '<p><b><font color="red" size="2">You forgot to enter your email address.</font></b></p>';
}
//check for comments
if (strlen($comments) > 0) {
$comments = stripslashes($comments);
} else {
$comments = NULL;
echo '<p><b><font color="red" size="2">You forgot to enter your comments.</font></b></p>';
}
function could_be_email($email) {
return preg_match('/^[^@]{1,64}@[^@]{4,255}$/', $email);
}
$from ="From: blah@blah.com $email";
if ($firstname && $email && $lastname && $phonenumber && $comments) {
$body = "First Name:'{$_POST['firstname']}'
Last Name:'{$_POST['lastname']}'
Phone Number:'{$_POST['phonenumber']}'
Email:'{$_POST['email']}'
Comments:'{$_POST['comments']}' ";
mail('blah@blah.com', 'webform inquiry', $body, $from);
echo '<font color="black" size="2" face="arial"><p>Thank you for your interest in Aloha Computers. We will call or email regarding your inquiry within 24 hours. Please feel free to call us at: (808) 372-2667 <br/>
<br/>
</font>';
} else {
echo '<p><font color="black" size="2"><b>Please try again.</b></font></p>';
}feyd | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]