Hi I wrote following form processing script that I got partially to work. everything works (validation and adding name and email to header), but I can't get it to add the content in the body, I have saved all contents in the variable $body here it is:
function VerifyForm(&$values, &$errors)
{
if (strlen($values['name']) < 3)
$errors['name'] = 'Name too short';
elseif (strlen($values['name']) > 40)
$errors['name'] = 'Name too long';
if (!ereg('.*@.*\..{2,4}', $values['email']))
$errors['email'] = 'Email address invalid';
else {if(isset($_POST['submit'])){
}
$company = $_POST['company'];
$new_design = $_POST['new_design'];
$redesign = $_POST['redesign'];
$ecommerce = $_POST['ecommerce'];
$programming = $_POST['programming'];
$current_url = $_POST['current_url'];
$products = $_POST['products'];
$graphic = $_POST['graphic'];
$colors = $_POST['colors'];
$websites = $_POST['websites'];
$start = $_POST['start'];
$deadline = $_POST['deadline'];
$hosting = $_POST['hosting'];
$budget = $_POST['budget'];
$comment= $_POST['comment'];
};
return (count($errors) == 0);
}
function DisplayForm($values, $errors)
{
$body = "Confirmation: $confirm\n\n\n
Name: $name\n
Email: $email\n
Company: $company\n
Services selected:\n
$graphic\n\n
products: $products\n
colors: $colors\n
websites I like: $websites\n
When Would you like to start: $start\n
Project deadline: $deadline\n
Budget: $budget\n
Details/Comments :$comment
";
<form>
all field are here
</form>
</body>
</html>
<?php
}
function ProcessForm($values)
{
mail('myemail@domain.com', "response" , $body, "From: \"{$values['name']}\ <{$values['email']}>");
echo "Sent ";
}
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
$formValues = $_POST;
$formErrors = array();
if (!VerifyForm($formValues, $formErrors))
DisplayForm($formValues, $formErrors);
else
ProcessForm($formValues);
}
else
DisplayForm(null, null);
?>