Mombu the Php Forum

Go Back   Mombu the Php Forum > Php > email form
User Name
Password
REGISTER NOW! Mark Forums Read




Reply
1 3rd July 00:32
romina
External User
 
Posts: 1
Default email form



Hi,
I've created this code for an email form. Unfortunately, the form is send
out even if the required fields are not in filled in. How can I change the
code to have people fill in all required fields? Can someone help?

<?
$name=$_POST['name'];
$job=$_POST['job'];
$phone=$_POST['phone'];
$fax=$_POST['fax'];
$address=$_POST['address'];
$postcode=$_POST['postcode'];
$email=$_POST['email'];
$category=$_POST['category'];

if (!$name && !$phone && !$address && !$postcode && !$email && !$category)
{
echo "Sorry you didn't answer all questions. Please go back to the form.";
}
else {
echo "Thank you.";

$toaddress = "email@xy.com";
$subject = "Form";
$mailcontent ="Name ".$_POST['name']."\n"
."Job Title ".$_POST['job']."\n"
."Organisation ".$_POST['organisation']." \n"
."Phone ".$_POST['phone']."\n"
."Fax ".$_POST['fax']."\n"
."Address ".$_POST['address']."\n"
."Postcode ".$_POST['postcode']."\n";

mail($toaddress, $subject, $mailcontent);
}
?>

Thanks,
Romina
  Reply With Quote


 


Reply


Thread Tools
Display Modes




666