Hi, all I have a project i'm working on. Here are the details.
I'm using Smarty for Templating. Sessions to capture form variables submitted as user hops from page to page. There are a total of 4 pages each submitting a bit of data. On the 4th page once the form is submitted I want to send an email to the administrator with all the submitted form data.
Here is my form.php script:
<?
session_name('mysession');
session_start();
//Registered Session Vars
$SESSION['submit_1'] = $POST['submit_1'];
$SESSION['submit_2'] = $POST['submit_2'];
$SESSION['submit_3'] = $POST['submit_3'];
$SESSION['submit_4'] = $POST['submit_4'];
$SESSION['goToStep'] = $POST['goToStep'];
$_SESSION['goBackTo'] = $POST['goBackTo'];
//Regiserted Form Session Vars
//Page 4.
$SESSION['first_name'] = $POST['first_name'];
$SESSION['last_name'] = $POST['last_name'];
$SESSION['address'] = $POST['address'];
$SESSION['city'] = $POST['city'];
$SESSION['stateCode'] = $POST['stateCode'];
$SESSION['zipcode'] = $POST['zipcode'];
$SESSION['day_npa'] = $POST['day_npa'];
$SESSION['day_nxx'] = $POST['day_nxx'];
$SESSION['day_station'] = $POST['day_station'];
$SESSION['day_ext'] = $POST['day_ext'];
$SESSION['eve_npa'] = $POST['eve_npa'];
$SESSION['eve_nxx'] = $POST['eve_nxx'];
$SESSION['eve_station'] = $POST['eve_station'];
$SESSION['email'] = $POST['email'];
$SESSION['BestTime'] = $POST['BestTime'];
//Page 3.
$SESSION['annualIncome'] = $POST['annualIncome'];
$SESSION['occupational_status'] = $POST['occupational_status'];
$SESSION['monthlyDebtPayments'] = $POST['monthlyDebtPayments'];
$SESSION['bankruptcy'] = $POST['bankruptcy'];
//Page 2.
$SESSION['loan_purpose'] = $POST['loan_purpose'];
$SESSION['homepurchaseyear'] = $POST['homepurchaseyear'];
$SESSION['home_value_preset'] - $POST['home_value_preset'];
$SESSION['mortgage1_balance'] = $POST['mortgage1_balance'];
$SESSION['m1IrDDa'] = $POST['m1IrDDa'];
$SESSION['m1IrDDb'] = $POST['m1IrDDb'];
$SESSION['mortgageRateType'] = $POST['mortgageRateType'];
$SESSION['second_mortgage'] = $POST['second_mortgage'];
$SESSION['m2IrDDa'] = $POST['m2IrDDa'];
$_SESSION['m2IrDDb'] = $POST['m2IrDDb'];
//Page 1.
$SESSION['propertyStateCode'] = $POST['propertyStateCode'];
$SESSION['propertyDesc'] = $POST['propertyDesc'];
$SESSION['credit_rating'] = $POST['credit_rating'];
$SESSION['typeOfLoan'] = $POST['typeOfLoan'];
//Forward Nav
if (isset($POST['submit_1'])) {
echo (require_once('step2.php'));
exit;
}elseif (isset($POST['submit_2'])) {
echo (require_once('step3.php'));
exit;
}elseif (isset($POST['submit_3'])) {
echo (require_once('step4.php'));
exit;
}elseif (isset($POST['submit_4'])) {
echo (require_once('thankyou.php'));
exit;
}else {
echo "There has beed a problem processing you request. Please contact us at 1-888-222-2222. We apologies for the inconviniance.";
}
// Send email function:
function sendemail() {
$emailTo = '"administrator" <admin@somewhere.com>';
$emailSubject = "Mysite: mysite.com";
$emailHeader = "From: {$SESSION['email']}\n"
. "Reply-To: {$SESSION['email']}\n"
. "MIME-Version: 1.0\n"
. "Content-type: text/plain; charset=\"ISO-8859-1\"\n"
. "Content-transfer-encoding: quoted-printable\n";
$emailBody =
" "
."Mortgage Quote Request\n"
."\n"
."\n"
."Contact Information"
. "\n"
. "First Name:..................:{$POST['first_name']}\n"
. "Last Name:...................:{$POST['last_name']}\n"
. "Address:.......................:{$POST['address']}\n"
. "City:..............................:{$POST['city']}\n"
. "State:............................:{$POST['stateCode']}\n"
. "Zip Code:......................:{$POST['zipcode']}\n"
. "Preferred Number:.......:{$POST['day_npa']}.{$POST['day_nxx']}.{$POST['day_station']}.{$POST['day_ext']}\n"
. "Alternate Number:.......:{$POST['eve_npa']}.{$POST['eve_nxx']}.{$POST['eve_station']}\n"
. "Email:...........................:{$POST['email']}\n"
. "Best Time to Call:.........:{$POST['BestTime']}\n"
." \n"
. "Property Information\n"
."\n"
. "Subject Property State:..:{$POST['propertyStateCode']}\n"
. "Subject Description:.......:{$POST['propertyDesc']}\n"
. "Credit Rating:.................:{$POST['credit_rating']}\n"
. "Loan Type:......................:{$POST['typeOfLoan']}\n"
. "Loan Purpose:.................:{$POST['refi_purpose']}\n"
. "Property Purchased:.......:{$POST['homepurchaseyear']}\n"
. "Estimate Value:..............:{$POST['home_value_preset']}\n"
. "Other Value:...................:{$POST['home_value_other']}\n"
. "Mortgage Balance:..........:{$POST['mortgage1_balance']}\n"
. "Current Rate:.................:{$POST['m1IrDDa']}.{$POST['m1IrDDb']}\n"
. "Mortgage Type:...............:{$POST['mortgageRateType']}\n"
. "Second Mortgage:...........:{$POST['second_mortgage']}\n"
. "2nd Current Balance:......:{$POST['mortgage2_balance']}\n"
. "Current Rate:..................:{$POST['m2IrDDa']}.{$POST['m2IrDDb']}\n"
. "\n"
. "Income Incormation\n"
. "\n"
. "Annual Income:..............:{$POST['annualIncome']}\n"
. "Occupation:....................:{$POST['occupational_status']}\n"
. "Est. Monthly debt:..........:{$POST['monthlyDebtPayments']}\n"
. " Bankruptcy:...................:{$_POST['bankruptcy']}\n"
. "\n"
. " \n ";
mail($emailTo, $emailSubject, $emailBody, $emailHeader);
}
//Final Submission E-mail Function
if(isset($_POST['submit_4'])) {
sendemail();
} else {
echo " Our server encountered an error. Your information was not sent.";
}
?>
If anyone can assist me in getting this to work that would be awsome. For wome reason the sendemail(); fundtion does not send the e-mail. Also, is it possible to send the e-mail in html format with all the data fields being populated by the form data...like in a html table? Let me know if anyone can help. Thanks!