I've looked all over for a PHP mail form that has validation and makes sense. Since I am very new to php, does anyone know of a place/script that will do this?
Announcement
Collapse
No announcement yet.
PHP Mail form with validation?
Collapse
X
-
Tags: None
-
i have one but please tell me what your definition of validation is-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
There are 3 kinds of ppl those who can count and those who cant
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Script-Megafest.com Coming Oh so very soon
-
Originally posted by Al_90i have one but please tell me what your definition of validation is
Comment
-
Originally posted by _Aerospace_Eng_Maybe you can adjust this one to fit your needs. It has javascript and server side validation.
The validation doesnt work with my page setup.
I just have
<?php include(" headers.php") ?>
this is the page
<?php include ("footers.php") ?>
Comment
-
aight, i got 1 that does dat, here it is:
PHP Code:<?php if($_GET['contact']) {
$to = "[email protected]";
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$email = $_POST['email'];
$mesage = $_POST['mesage'];
$sub = "Contact email form yoursitename";
$headers = "From: $fname $lname <$email>\n";
$headers .= "Content-Type: text/plain; charset=iso-8859-1\n";
$mes = "First Name: ".$fname."\n";
$mes .= "Last Name: ".$lname."\n";
$mes .= "Email: ".$email."\n";
$mes .= "Message: ".$mesage."\n";
if(empty($fname) || empty($lname) || empty($email) || empty($mesage)) {
echo " <h3><center>Please fill out all the fields</center></h3>";
} elseif(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {
print " <<h3><center>Sorry the email address you entered looks like it's invalid</center></h3>";
} else {
mail($to, $sub, $mes, $headers);
print " <h3><center>Thank you. ".$fname." we will respond within 24-48 hours </center></h3>";
}
}
?>
<form method="post" action="?contact=true">
<div align="center">
First Name: <input name="fname" type="text" size="30"><br>
Last Name: <input name="lname" type="text" size="30"><br>
Email: <input name="email" type="text" size="30"><br>
Message:<br><textarea name="mesage" cols="50" rows="5"></textarea>
<br>
</div>
</form>-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
There are 3 kinds of ppl those who can count and those who cant
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Script-Megafest.com Coming Oh so very soon
Comment
-
Originally posted by Al_90aight, i got 1 that does dat, here it is:
PHP Code:<?php if($_GET['contact']) {
$to = "[email protected]";
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$email = $_POST['email'];
$mesage = $_POST['mesage'];
$sub = "Contact email form yoursitename";
$headers = "From: $fname $lname <$email>\n";
$headers .= "Content-Type: text/plain; charset=iso-8859-1\n";
$mes = "First Name: ".$fname."\n";
$mes .= "Last Name: ".$lname."\n";
$mes .= "Email: ".$email."\n";
$mes .= "Message: ".$mesage."\n";
if(empty($fname) || empty($lname) || empty($email) || empty($mesage)) {
echo " <h3><center>Please fill out all the fields</center></h3>";
} elseif(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {
print " <<h3><center>Sorry the email address you entered looks like it's invalid</center></h3>";
} else {
mail($to, $sub, $mes, $headers);
print " <h3><center>Thank you. ".$fname." we will respond within 24-48 hours </center></h3>";
}
}
?>
<form method="post" action="?contact=true">
<div align="center">
First Name: <input name="fname" type="text" size="30"><br>
Last Name: <input name="lname" type="text" size="30"><br>
Email: <input name="email" type="text" size="30"><br>
Message:<br><textarea name="mesage" cols="50" rows="5"></textarea>
<br>
</div>
</form>
I got it working, I just had to put all the code onto the contact page instead of using includes.Last edited by Ranger56; Aug 3, 2005, 05:14 PM.
Comment
-
mine or his?-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
There are 3 kinds of ppl those who can count and those who cant
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Script-Megafest.com Coming Oh so very soon
Comment
-
Comment
-
looks nice, glad i could help-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
There are 3 kinds of ppl those who can count and those who cant
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Script-Megafest.com Coming Oh so very soon
Comment
Comment