Hey guys,
I’ve been trying to make a php feedback form on one of the pages of my website. It uses echos to display the form and potential error messages, both html and php are therefore in the same file. It’s displaying the form correctly (you can see it here: www.compillini.com/Design.php) but nothing works! I don’t receive an email and none of the echo scripts are popping up anywhere!
Here is the form code:
[php]
<?php
// Function to display form
function showForm($errorName=false,$errorEmail=false,$errorMesg=false){
if ($errorName) $errorTextName = "Please enter your name!";
if ($errorEmail) $errorTextEmail = "Please enter a valid email address!";
if ($errorMesg) $errorTextMesg = "Please leave a longer message!";
echo '
';
// Display name field an error if needed
echo '
Name * |
|
';
if ($errorName) echo "$errorTextName |
";
// Display email field an error if needed
echo '
Email * |
|
';
if ($errorEmail) echo "$errorTextEmail |
";
echo '
Phone |
|
';
// Display message field an error if needed
echo ' |
';
if ($errorMesg) echo "$errorTextMesg |
";
echo ' |
';
echo '
';
}
if (!isset($_POST['submit'])) {
showForm() ;
} else {
//Init error variables
$errorName = false;
$errorEmail = false;
$errorMesg = false;
$name = isset($_POST['name']) ? trim($_POST['name']) : '';
$email = isset($_POST['email']) ? trim($_POST['email']) : '';
$mesg = isset($_POST['comments']) ? trim($_POST['comments']) : '';
if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) $errorEmail = true;
if (strlen($name)<3) $errorName = true;
if (strlen($mesg)<100) $errorMesg = true;
// Display the form again as there was an error
if ($errorName || $errorEmail || $errorMesg) {
showForm($errorName,$errorEmail,$errorMesg);
} else {
echo 'Submission was successful!';
}
mail( "
[email protected]", "Appointment from $name",
$message, "From: $email" );
}
?>
[/php]
Again, the form is here:
http://www.compillini.com/Design.php
Thank you very much for your help!
Tim