Really desperate need of experienced folks on this one!!
I built a form in which the client wants every field required and the data sent via email. This is what I have: warning, it is a lot!!
<?php
//requires
require_once('validation.php');
//set master email
define('EMAIL', 'lisaroser@gmail.com');
//report errors
ini_set('display_errors', 'On');
error_reporting(E_ALL);
if(@$_POST['submitted'])
{
//create vars for easier use
//$_REQUEST contains BOTH $_GET and $_POST
$owners = $_POST['owners'];
$parcel = $_POST['parcel'];
$address = $_POST['address'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$county = $_POST['county'];
$code = $_POST['code'];
$txYear = $_POST['txYear'];
$reTaxes = $_POST['reTaxes'];
$sellPrice = $_POST['sellPrice'];
$sellDate = $_POST['sellDate'];
$sqFt = $_POST['sqFt'];
$age = $_POST['age'];
$bdrm = $_POST['bdrm'];
$baths = $_POST['baths'];
$bsmnt = $_POST['bsmnt'];
$garage = $_POST['garage'];
$stories = $_POST['stories'];
$style = $_POST['style'];
$other = $_POST['other'];
$use = $_POST['use'];
$verify = $_POST['verify'];
$submit = $_POST['submit'];
//Validate user input. Create error array to store errors
$error_msg = array();
$valid = verifyAlpha($owners);
if(!$valid)
{
$error_msg[] = 'invalid name.';
$user_error = '<span class="error">Please provide a valid owner name.</span>';
}
$valid = verifyAlphaNum($parcel);
if(!$valid)
{
$error_msg[] = 'invalid number.';
$user_error = '<span class="error">Please provide a the parcel number.</span>';
}
$valid = verifyAlphaNum($address);
if(!$valid)
{
$error_msg[] = 'invalid address.';
$email_error = '<span class="error">Please provide the address of the parcel.</span>';
}
$valid = verifyAlpha($city);
if(!$valid)
{
$error_msg[] = 'invalid city.';
$email_error = '<span class="error">Please provide the city.</span>';
}
$valid = verifyAlpha($state);
if(!$valid)
{
$error_msg[] = 'invalid state.';
$email_error = '<span class="error">Please provide the state.</span>';
}
$valid = verifyNum($zip);
if(!$valid)
{
$error_msg[] = 'invalid zip code.';
$email_error = '<span class="error">Please provide a valid zip code.</span>';
}
$valid = verifyAlpha($county);
if(!$valid)
{
$error_msg[] = 'invalid county.';
$email_error = '<span class="error">Please provide the county name.</span>';
}
$valid = verifyAlphaNum($code);
if(!$valid)
{
$error_msg[] = 'invalid code.';
$email_error = '<span class="error">Please provide the parcel code.</span>';
}
$valid = verifyNum($txYear);
if(!$valid)
{
$error_msg[] = 'invalid txYear.';
$email_error = '<span class="error">Please provide the tax year.</span>';
}
$valid = verifyNum($reTaxes);
if(!$valid)
{
$error_msg[] = 'invalid RE Taxes.';
$email_error = '<span class="error">Please provide the RE tax amount.</span>';
}
$valid = verifyNum($sellPrice);
if(!$valid)
{
$error_msg[] = 'invalid number.';
$email_error = '<span class="error">Please provide the sale amount.</span>';
}
$valid = verifyAlphaNum($sellDate);
if(!$valid)
{
$error_msg[] = 'invalid date.';
$email_error = '<span class="error">Please provide the date on the contract.</span>';
}
$valid = verifyNum($sqFt);
if(!$valid)
{
$error_msg[] = 'invalid number.';
$email_error = '<span class="error">Please provide the square footage of the building.</span>';
}
$valid = verifyNum($age);
if(!$valid)
{
$error_msg[] = 'invalid number.';
$email_error = '<span class="error">Please provide the age.</span>';
}
$valid = verifyNum($bdrm);
if(!$valid)
{
$error_msg[] = 'invalid number.';
$email_error = '<span class="error">Please provide the number of bedrooms.</span>';
}
$valid = verifyNum($baths);
if(!$valid)
{
$error_msg[] = 'invalid number.';
$email_error = '<span class="error">Please provide the number of baths.</span>';
}
$valid = verifyNum($garage);
if(!$valid)
{
$error_msg[] = 'invalid number.';
$email_error = '<span class="error">Please provide the garage square footage.</span>';
}
$valid = verifyNum($stories);
if(!$valid)
{
$error_msg[] = 'invalid number.';
$email_error = '<span class="error">Please provide the number of stories.</span>';
}
$valid = verifyAlpha($style);
if(!$valid)
{
$error_msg[] = 'invalid entry.';
$email_error = '<span class="error">Please provide the style type of the house.</span>';
}
$valid = verifyAlphaNum($other);
if(!$valid)
{
$error_msg[] = 'invalid entry.';
$email_error = '<span class="error">Please provide any additional information.</span>';
}
$valid = verifyAlphaNum($use);
if(!$valid)
{
$error_msg[] = 'invalid entry.';
$email_error = '<span class="error">Please provide the useage of the property.</span>';
}
/*$valid = verifyCheck($verify);
if(!$valid)
{
$error_msg[] = 'invalid entry';
$email_error = '<span class="error">Please check the box to send form.</span>';
}*/
//if any errors, don't send email - else send email
if(count($error_msg) === 0)
{
//prepare for sending email
$destination = EMAIL;
$subject = 'Pre-Determination Analysis Form';
$body = "From: $owners\n Parcel: $parcel\n Address: $address \n City: $city \n State: $state \n Zip: $zip \n County: $county \n Code: $code \n Tax Year: $txYear \n RE Taxes$reTaxes \n Selling Contract Price: $sellPrice \n Selling Contract Date: $sellDate \n Total Sq Ft (Gross Livable): $sqFt \n Age: $age \n No. of Bedrooms: $bdrm \n No. of Baths: $baths \n Basement Sq. Ft. (Finished): $bsmnt \n Garage Sq. Ft. (Finished): $garage \n No. Stories: $stories \n Style: $style \n Other: $other Use: \n $use";
if(mail($destination, $subject, $body))
{
echo 'Your message has been sent. Below is the info you provided:';
//test to see if form data is recieved.
echo '<h1>Thanks for providing feedback</h1>';
echo '<ul>';
echo '<li>' . $_POST['owner'] . '</li>';
echo '<li>' . $_POST['city'] . '</li>';
echo '<li>' . $_POST['state'] . '</li>';
echo '</ul>';
}
else
{
echo 'There was an error. Your message has NOT been sent.';
}
}//if count end
} //ends if submitted
?>
i am using MAMP to work it out. If i leave every field blank & hit submit, it does nothing. When I enter data, hit submit nothing happens. When I enter the wrong data types as defined in the validation, I get nothing. I think you get the point.
The worst part is, I think it is something really 'stoopit! 😉
Here's the link:
http://ptr.hollielizabethdesign.com/preDetermine.html
The page the form appears in, is not the page that actually contains the form. The form is placed into a different page using iframe, which is the URL above. This came from the client so I did not change it.
I cannot tell you how much I appreciate the help. If you can suggest ways to solve this on my own next time, that wold also be a tremendous service!!
Have a good one!!
Lisa