Page 1 of 1
PHP - Online Booking Form
Posted: Tue Nov 10, 2009 7:40 am
by ahbb
HI All,
Please help me as im pulling my hair out of not getting this right.
I have a client that we made a online booking form, now the client want went some 1 fill in the form the form must be emailed to the user and to the person that made the booking.
This is our testing code that we did but it works and send out the email to the client but not to the user that did fill in form.
As we still need to put a message in what the person get when they get a copy of the details they filled in. I don't know where to put that in either some help would be appreciated.
Code: Select all
<?php
# Just some quick changeable options
$SendTo = 'test@test.co.za'; # The desired email address to which the booking email is sent to
$Subject = 'Website Booking'; # The subject used in the emails
$SendToClient = true; # True or false, should the script send an email to the person submitting the form too?
# If the form has been submitted
if (array_key_exists('submitDetails', $_POST))
{
# Quick reference to $_POST (its uppercase, underscored and just nasty :|)
$Form =& $_POST;
# Build up all of the email headers into a php array (change here as desired)
$aHeaders = array(
'From' => "Website <noreply@test.co.za>",
'X-Mailer' => 'Contact Form'
);
# Now, loop through each of the specified headers and compile the string version
$Headers = '';
foreach ($aHeaders as $sKey => $sValue)
$Headers .= "{$sKey}: {$sValue}\r\n";
# Compose the booking email
$Message = <<<TEXT
Some fellow attempted to make an online booking, whoooopeeee!
Firstname: {$Form['firstname']}
Lastname: {$Form['lastname']}
Email Address: {$Form['email']}
Note: {$Form['note']}
Joy!
TEXT;
# Send the first email to the desired email address
if (!@mail($Form['email'], $Subject, $Message, $Headers))
die('Unable to send booking email!');
}
?>
Thanks
Andrew

Re: PHP - Online Booking Form - URGENT - PLS HELP
Posted: Wed Nov 11, 2009 2:18 am
by ahbb
HI,
I got most of the things right but now the only thing is.
That it dont want to send the 2nd email to the person that submit the form.
Please see my coding and advice on it.
I really need to get this fix it urgent!
Code: Select all
<?php
# Just some quick changeable options
$SendTo = 'test@test.co.za'; # The desired email address to which the booking email is sent to
$Subject = 'Website Booking'; # The subject used in the emails
$SendToClient = true; # True or false, should the script send an email to the person submitting the form too?
# If the form has been submitted
if (array_key_exists('submitDetails', $_POST))
{
# Quick reference to $_POST (its uppercase, underscored and just nasty :|)
$Form =& $_POST;
# Build up all of the email headers into a php array (change here as desired)
$aHeaders = array(
'From' => "TEst <test@test.co.za>",
'X-Mailer' => 'Test Online Booking Form'
);
# Now, loop through each of the specified headers and compile the string version
$Headers = '';
foreach ($aHeaders as $sKey => $sValue)
$Headers .= "{$sKey}: {$sValue}\r\n";
# Compose the booking email
$Message = <<<TEXT
The following information has been submited via http://www.dai-heka.co.za
Name: {$Form['name']}
Surname: {$Form['surname']}
Physical Address: {$Form['physical_address']}
Postal Address: {$Form['postal_address']}
Tel Home: {$Form['tel_home']}
Tel Work: {$Form['tel_work']}
Fax: {$Form['fax']}
Email Address: {$Form['email']}
Accommodation Type: {$Form['accommodation_type']}
Arrival Day: {$Form['arrival_day']}
Arrival Month: {$Form['arrival_month']}
Arrival Year: {$Form['arrival_year']}
Departure Day: {$Form['departure_day']}
Departure Month: {$Form['departure_month']}
Departure Year: {$Form['departure_year']}
Number of Adults: {$Form['number_of_adults']}
Number of Children: {$Form['number_of_children']}
Special Requests: {$Form['special_requests']}
TEXT;
# Send the first email to the desired email address
if (!@mail($Form['email'], $Subject, $Message, $Headers))
die('Unable to send booking email!');
# Compose the Client booking email
$Message = <<<TEXT
msg :
Name: {$Form['name']}
Surname: {$Form['surname']}
Physical Address: {$Form['physical_address']}
Postal Address: {$Form['postal_address']}
Tel Home: {$Form['tel_home']}
Tel Work: {$Form['tel_work']}
Fax: {$Form['fax']}
Email Address: {$Form['email']}
Accommodation Type: {$Form['accommodation_type']}
Arrival Day: {$Form['arrival_day']}
Arrival Month: {$Form['arrival_month']}
Arrival Year: {$Form['arrival_year']}
Departure Day: {$Form['departure_day']}
Departure Month: {$Form['departure_month']}
Departure Year: {$Form['departure_year']}
Number of Adults: {$Form['number_of_adults']}
Number of Children: {$Form['number_of_children']}
Special Requests: {$Form['special_requests']}
TEXT;
# Send the second email to the desired email address
if (!@mail($From['email'], $Subject, $Message, $Headers))
die('Unable to send email to user submitting!');
}
?>
<html>
<head>
<title>Dai Heka Online Booking Form</title>
</head>
<body>
<form action="onlinebooking.php" method="post" enctype="multipart/form-data">
<input type="hidden" name="submitDetails" value="true" />
<table border="0" align="center" cellpadding="2">
<tr>
<td valign="top" nowrap bgcolor="#bd9075"><strong><font face="Verdana" size="2" color="#6e2808">Name</font></strong></td>
<td valign="top" bgcolor="#bd9075"> <font color="#6e2808">
<input name="name" type="text" id="name" value="" size="30" maxlength="100">
</font></td>
</tr>
<tr>
<td valign="top" nowrap bgcolor="#bd9075"><strong><font face="Verdana" size="2" color="#6e2808">Surname</font></strong></td>
<td valign="top" bgcolor="#bd9075"> <font color="#6e2808">
<input name="surname" type="text" id="surname" value="" size="30" maxlength="100">
</font></td>
</tr>
<tr>
<td valign="top" nowrap bgcolor="#bd9075"><strong><font face="Verdana" size="2" color="#6e2808">Physical
Address</font></strong></td>
<td valign="top" bgcolor="#bd9075"> <font color="#6e2808">
<textarea name="physical_address" cols="20" rows="10" id="physical address"></textarea>
<br>
</font></td>
</tr>
<tr>
<td valign="top" nowrap bgcolor="#bd9075"><strong><font face="Verdana" size="2" color="#6e2808">Postal
Address</font></strong></td>
<td valign="top" bgcolor="#bd9075"> <font color="#6e2808">
<textarea name="postal_address" cols="20" rows="10" id="postal address"></textarea>
<br>
</font></td>
</tr>
<tr>
<td valign="top" nowrap bgcolor="#bd9075"><strong><font face="Verdana" size="2" color="#6e2808">Tel
Home</font></strong></td>
<td valign="top" bgcolor="#bd9075"> <font color="#6e2808">
<input name="tel_home" type="text" id="tel home" value="" size="30" maxlength="100">
</font></td>
</tr>
<tr>
<td valign="top" nowrap bgcolor="#bd9075"><strong><font face="Verdana" size="2" color="#6e2808">Tel
Work</font></strong></td>
<td valign="top" bgcolor="#bd9075"> <font color="#6e2808">
<input name="tel_work" type="text" id="tel work" value="" size="30" maxlength="100">
</font></td>
</tr>
<tr>
<td valign="top" nowrap bgcolor="#bd9075"><strong><font face="Verdana" size="2" color="#6e2808">Fax</font></strong></td>
<td valign="top" bgcolor="#bd9075"> <font color="#6e2808">
<input name="fax" type="text" id="fax" value="" size="30" maxlength="100">
</font></td>
</tr>
<tr>
<td valign="top" nowrap bgcolor="#bd9075"><strong><font face="Verdana" size="2" color="#6e2808">Email
Address </font></strong></td>
<td valign="top" bgcolor="#bd9075"> <font color="#6e2808">
<input name="email" type="text" id="email" value="" size="30" maxlength="100">
</font></td>
</tr>
<tr>
<td valign="top" nowrap bgcolor="#bd9075"><strong><font face="Verdana" size="2" color="#6e2808">Accommodation
Type </font></strong></td>
<td valign="top" bgcolor="#bd9075"> <font color="#6e2808">
<select name="accommodation_type" id="accommodation type">
<option value="None ">None </option>
<option value=" Guest House "> Guest House </option>
<option value=" Self Catering "> Self Catering </option>
<option value=" Group Booking "> Group Booking </option>
<option value=" Conference "> Conference </option>
<option value=" Function "> Function </option>
<option value=" Wedding Venue"> Wedding Venue</option>
</select>
</font></td>
</tr>
<tr>
<td valign="top" nowrap bgcolor="#bd9075"><strong><font face="Verdana" size="2" color="#6e2808">Arrival
Day</font></strong></td>
<td valign="top" bgcolor="#bd9075"> <font color="#6e2808">
<select name="arrival_day" id="arrival day">
<option value="Day ">Day </option>
<option value=" 1 "> 1 </option>
<option value=" 2 "> 2 </option>
<option value=" 3 "> 3 </option>
<option value=" 4 "> 4 </option>
<option value=" 5 "> 5 </option>
<option value=" 6 "> 6 </option>
<option value=" 7 "> 7 </option>
<option value=" 8 "> 8 </option>
<option value=" 9 "> 9 </option>
<option value=" 10 "> 10 </option>
<option value=" 11 "> 11 </option>
<option value=" 12 "> 12 </option>
<option value=" 13 "> 13 </option>
<option value=" 14 "> 14 </option>
<option value=" 15 "> 15 </option>
<option value=" 16 "> 16 </option>
<option value=" 17 "> 17 </option>
<option value=" 18 "> 18 </option>
<option value=" 19 "> 19 </option>
<option value=" 20 "> 20 </option>
<option value=" 21 "> 21 </option>
<option value=" 22 "> 22 </option>
<option value=" 23 "> 23 </option>
<option value=" 24 "> 24 </option>
<option value=" 25 "> 25 </option>
<option value=" 26 "> 26 </option>
<option value=" 27 "> 27 </option>
<option value=" 28 "> 28 </option>
<option value=" 29 "> 29 </option>
<option value=" 30 "> 30 </option>
<option value=" 31"> 31</option>
</select>
</font></td>
</tr>
<tr>
<td valign="top" nowrap bgcolor="#bd9075"><strong><font face="Verdana" size="2" color="#6e2808">Arrival
Month</font></strong></td>
<td valign="top" bgcolor="#bd9075"> <font color="#6e2808">
<select name="arrival_month" id="arrival month">
<option value="Month ">Month </option>
<option value=" January "> January </option>
<option value=" February "> February </option>
<option value=" March "> March </option>
<option value=" April "> April </option>
<option value=" May "> May </option>
<option value=" June "> June </option>
<option value=" July "> July </option>
<option value=" August "> August </option>
<option value=" September "> September </option>
<option value=" October "> October </option>
<option value=" November "> November </option>
<option value=" December"> December</option>
</select>
</font></td>
</tr>
<tr>
<td valign="top" nowrap bgcolor="#bd9075"><strong><font face="Verdana" size="2" color="#6e2808">Arrival
Year</font></strong></td>
<td valign="top" bgcolor="#bd9075"> <font color="#6e2808">
<select name="arrival_year" id="arrival year">
<option value="Year">Year </option>
<option value=" 2009"> 2009 </option>
<option value=" 2010"> 2010 </option>
<option value=" 2011"> 2011</option>
</select>
</font></td>
</tr>
<tr>
<td valign="top" nowrap bgcolor="#bd9075"><strong><font face="Verdana" size="2" color="#6e2808">Departure
Day</font></strong></td>
<td valign="top" bgcolor="#bd9075"> <font color="#6e2808">
<select name="departure_day" id="departure day">
<option value="Day ">Day </option>
<option value=" 1 "> 1 </option>
<option value=" 2 "> 2 </option>
<option value=" 3 "> 3 </option>
<option value=" 4 "> 4 </option>
<option value=" 5 "> 5 </option>
<option value=" 6 "> 6 </option>
<option value=" 7 "> 7 </option>
<option value=" 8 "> 8 </option>
<option value=" 9 "> 9 </option>
<option value=" 10 "> 10 </option>
<option value=" 11 "> 11 </option>
<option value=" 12 "> 12 </option>
<option value=" 13 "> 13 </option>
<option value=" 14 "> 14 </option>
<option value=" 15 "> 15 </option>
<option value=" 16 "> 16 </option>
<option value=" 17 "> 17 </option>
<option value=" 18 "> 18 </option>
<option value=" 19 "> 19 </option>
<option value=" 20 "> 20 </option>
<option value=" 21 "> 21 </option>
<option value=" 22 "> 22 </option>
<option value=" 23 "> 23 </option>
<option value=" 24 "> 24 </option>
<option value=" 25 "> 25 </option>
<option value=" 26 "> 26 </option>
<option value=" 27 "> 27 </option>
<option value=" 28 "> 28 </option>
<option value=" 29 "> 29 </option>
<option value=" 30 "> 30 </option>
<option value=" 31"> 31</option>
</select>
</font></td>
</tr>
<tr>
<td valign="top" nowrap bgcolor="#bd9075"><strong><font face="Verdana" size="2" color="#6e2808">Departure
Month</font></strong></td>
<td valign="top" bgcolor="#bd9075"> <font color="#6e2808">
<select name="departure_month" id="departure month">
<option value="Month ">Month </option>
<option value=" January "> January </option>
<option value=" February "> February </option>
<option value=" March "> March </option>
<option value=" April "> April </option>
<option value=" May "> May </option>
<option value=" June "> June </option>
<option value=" July "> July </option>
<option value=" August "> August </option>
<option value=" September "> September </option>
<option value=" October "> October </option>
<option value=" November "> November </option>
<option value=" December"> December</option>
</select>
</font></td>
</tr>
<tr>
<td valign="top" nowrap bgcolor="#bd9075"><strong><font face="Verdana" size="2" color="#6e2808">Departure
Year</font></strong></td>
<td valign="top" bgcolor="#bd9075"> <font color="#6e2808">
<select name="departure_year" id="departure year">
<option value="Year ">Year </option>
<option value=" 2009 ">2009 </option>
<option value=" 2010">2010</option>
<option value="2011">2011</option>
</select>
</font></td>
</tr>
<tr>
<td valign="top" nowrap bgcolor="#bd9075"><strong><font face="Verdana" size="2" color="#6e2808">Number
of Adults</font></strong></td>
<td valign="top" bgcolor="#bd9075"> <font color="#6e2808">
<select name="number_of_adults" id="number of adults">
<option value="1 ">1 </option>
<option value=" 2 "> 2 </option>
<option value=" 3 "> 3 </option>
<option value=" 4 "> 4 </option>
<option value=" 5 "> 5 </option>
<option value=" 6 "> 6 </option>
<option value=" 7 "> 7 </option>
<option value=" 8 "> 8 </option>
<option value=" 9 "> 9 </option>
<option value=" 10"> 10</option>
</select>
</font></td>
</tr>
<tr>
<td valign="top" nowrap bgcolor="#bd9075"><strong><font face="Verdana" size="2" color="#6e2808">Number
of Children</font></strong></td>
<td valign="top" bgcolor="#bd9075"> <font color="#6e2808">
<select name="number_of_children" id="number of children">
<option value="None ">None </option>
<option value=" 1 "> 1 </option>
<option value=" 2 "> 2 </option>
<option value=" 3 "> 3 </option>
<option value=" 4 "> 4 </option>
<option value=" 5 "> 5 </option>
<option value=" 6 "> 6 </option>
<option value=" 7 "> 7 </option>
<option value=" 8 "> 8 </option>
<option value=" 9 "> 9 </option>
<option value=" 10"> 10</option>
</select>
</font></td>
</tr>
<tr>
<td valign="top" nowrap bgcolor="#bd9075"><strong><font face="Verdana" size="2" color="#6e2808">Special
Requests</font></strong></td>
<td valign="top" bgcolor="#bd9075"> <font color="#6e2808">
<textarea name="special_requests" cols="20" rows="10" id="special requests"></textarea>
<br>
</font></td>
</tr>
<tr bgcolor="#bd9075">
<td colspan="2"><div align="center"><font color="#6e2808" face="Verdana" size="2"><b>Image
Verification</b></font></div></td>
</tr>
<tr bgcolor="#bd9075">
<td colspan="2" style="padding: 2px;"><div align="center">
<script language=javascript src=http://www.cisin.com/imageverification/genCode.aspx?siteid=2410></script>
<font color="#6e2808"><strong>Please enter the text from the image</strong></font>
</div></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="reset" name="Reset" value="Reset">
<input name="Submit" type="submit" id="Submit" value="Submit">
</div></td>
</tr>
</table>
</form>
ahbb wrote:HI All,
Please help me as im pulling my hair out of not getting this right.
I have a client that we made a online booking form, now the client want went some 1 fill in the form the form must be emailed to the user and to the person that made the booking.
This is our testing code that we did but it works and send out the email to the client but not to the user that did fill in form.
As we still need to put a message in what the person get when they get a copy of the details they filled in. I don't know where to put that in either some help would be appreciated.
Code: Select all
<?php
# Just some quick changeable options
$SendTo = 'test@test.co.za'; # The desired email address to which the booking email is sent to
$Subject = 'Website Booking'; # The subject used in the emails
$SendToClient = true; # True or false, should the script send an email to the person submitting the form too?
# If the form has been submitted
if (array_key_exists('submitDetails', $_POST))
{
# Quick reference to $_POST (its uppercase, underscored and just nasty :|)
$Form =& $_POST;
# Build up all of the email headers into a php array (change here as desired)
$aHeaders = array(
'From' => "Website <noreply@test.co.za>",
'X-Mailer' => 'Contact Form'
);
# Now, loop through each of the specified headers and compile the string version
$Headers = '';
foreach ($aHeaders as $sKey => $sValue)
$Headers .= "{$sKey}: {$sValue}\r\n";
# Compose the booking email
$Message = <<<TEXT
Some fellow attempted to make an online booking, whoooopeeee!
Firstname: {$Form['firstname']}
Lastname: {$Form['lastname']}
Email Address: {$Form['email']}
Note: {$Form['note']}
Joy!
TEXT;
# Send the first email to the desired email address
if (!@mail($Form['email'], $Subject, $Message, $Headers))
die('Unable to send booking email!');
}
?>
Thanks
Andrew
