Contact form with required fields
Posted: Fri Feb 26, 2010 5:59 pm
I am trying to code some IF statements into PHP that warns if certain fields are not populated on my contact form (http://bigdogcattle.com/?a=Cattle_Contact). Here is the code I have so far, but it will send me an email even if nothing is populated:
<?php if (isset($_POST['name'])){
$header = 'From: ' .$_POST['email'] .'\r\nContent-type: text/plain; charset=iso-8859-1\r\n';
$body = 'Name:: '. $_POST['name'];
$body .= '\nEmail:: '. $_POST['email'];
$body .= '\nPhone:: '. $_POST['phone'];
$body .= '\nMessage:: '. $_POST['message'];
$body = wordwrap($body,70);
$send = mail('info@bigdogcattle.com', 'Form submitted from your website', $body, $header);
if($send){
echo '<h3>Your messages was successfully sent....</h3>';
}else{
echo '<h3>There was a problem sending this message....</h3>';
}
}?>
Thanks
Jamie
Http://bigdogcattle.com
<?php if (isset($_POST['name'])){
$header = 'From: ' .$_POST['email'] .'\r\nContent-type: text/plain; charset=iso-8859-1\r\n';
$body = 'Name:: '. $_POST['name'];
$body .= '\nEmail:: '. $_POST['email'];
$body .= '\nPhone:: '. $_POST['phone'];
$body .= '\nMessage:: '. $_POST['message'];
$body = wordwrap($body,70);
$send = mail('info@bigdogcattle.com', 'Form submitted from your website', $body, $header);
if($send){
echo '<h3>Your messages was successfully sent....</h3>';
}else{
echo '<h3>There was a problem sending this message....</h3>';
}
}?>
Thanks
Jamie
Http://bigdogcattle.com