brettanderson77
asked on
HTML email post with ASP script
Hi All,
I have three files:
mail.htm - a html email form
mymailer.asp - an asp mail handler script
enquiry_sent.htm - the redirection page after the mail form is sent
I want to be able to hit submit button in mail.htm, and have an email go to bca1977@hotmail.com and for the user to then be redirected to enquirey_sent.htm
Here is the script for the two key pages:
========================== ========== ========== ========== ====
mail.htm - only inlcluded relevant code - page also has other html
========================== ========== ========== ========== ====
<table cellspacing="2" cellpadding="2" border="0" align="center">
<form name="CFForm_1" action="mymailer.asp" method="post">
<input type="hidden" name="mail_categoryID" value="1">
<input type="hidden" name="mail_recipient" value="bca1977@hotmail.com ">
<input type="hidden" name="mail_subject" value="Batukarang Lembongan Request">
<input type="hidden" name="mail_redirect" value="/enquiry_sent.htm">
<tr>
<td colspan="2" align="center" valign="top" height="35">Please complete all fields marked with *
</td>
</tr>
<tr>
<td align="right" valign="top">Request Details :
</td>
<td><textarea name="request_details" cols="40" rows="6" wrap="virtual"></textarea> </td></tr>
<tr>
<td align="right">Check in date :
</td>
<td><input name="check_in" id="check_in" type="text" size="20"/></td></tr>
<tr>
<td align="right">Check out date :
</td>
<td><input name="check_out" id="check_out" type="text" size="20"/></td></tr>
<tr>
<td align="right">Room Type :
</td>
<td><select name="room_type">
<option value="">--- Please Select ---
<option value="Superior">Superior
<option value="Deluxe" selected>Deluxe
<option value="Romantic Room">Romantic Room
<option value="Family / 3 Bedded">Family / 3 Bedded
<option value="Superior Suite">Superior Suite
<option value="Deluxe Suite">Deluxe Suite
<option value="Bintang Bali Suite">Bintang Bali Suite
<option value="Special Needs">Special Needs
</select>
</td>
</tr>
<tr>
<td align="right">Number of rooms :
</td>
<td><input name="number_of_rooms" id="number_of_rooms" type="text" size="3" />
</td>
</tr>
<tr>
<td align="right">How many adults : </td>
<td><input name="how_many_adults" id="how_many_adults" type="text" size="3" />
</td>
</tr>
<tr>
<td align="right">How many children :
</td>
<td><input name="How_many_children" id="How_many_children" type="text" size="3" />
</td>
</tr>
<tr>
<td align="right">Airport Pick Up :
</td>
<td><input type="radio" name="airport_pick_up" value="Yes" style="background:">Yes
<input type="radio" name="airport_pick_up" value="No" style="background:" checked >No
</td>
</tr>
<tr>
<td align="right">Name * :
</td>
<td><input name="name" id="name" type="text" size="40" />
</td>
</tr>
<tr>
<td align="right">Email Address * :
</td>
<td><input name="email" id="email" type="text" size="40" />
</td>
</tr>
<tr>
<td align="right">City :
</td>
<td><input name="city" id="city" type="text" size="40" />
</td>
</tr>
<tr>
<td align="right">Country :
</td>
<td><input name="country" id="country" type="text" size="40"/>
</td>
</tr>
<tr>
<td align="right">Phone :
</td>
<td><input name="phone" id="phone" type="text" size="40" />
</td>
</tr>
<tr>
<td align="right">Fax :
</td>
<td><input name="fax" id="fax" type="text" size="40" />
</td>
</tr>
<tr>
<td align="right" valign="top">Comments :
</td>
<td><textarea name="comments" cols="40" rows="6" wrap="virtual"></textarea>
</td>
</tr>
<tr>
<td>
</td>
<td height="40" valign="bottom">
<input type="submit" value=" Submit " class="bt">
<input type="reset" value=" Clear " class="bt">
<input type="button" value=" Back " class="bt" onclick="javascript:histor y.back(1); ">
<!-- The back button won't work cause you don't have the javascript-->
</td>
</tr>
</form>
</table>
========================== ========== ========== ========== ========== ========== ==
mymailer.asp - please note this page has no other script - no html headers or anything
========================== ========== ========== ========== ========== ========== ==
<%
dim Body as string
body="New Reservation:" & vbcrlf
body=body & "Category ID=" & request.form("mail_categor yID") & vbcrlf
body=body & "Customer Name: " & request.form("name") & vbcrlf
'... continue building your email layout here
body=body & request.form("request_deta ils")
Set myMail=CreateObject("CDO.M essage")
myMail.Subject=request.for m("mail_su bject")
myMail.From=request.form(" mail_recip ient")
myMail.To=request.form("ma il_recipie nt")
myMail.TextBody=body
myMail.Send
set myMail=nothing
response.redirect("/reques t-info/ind ex.cfm?con f=ok")
%>
========================== ========== ========== ========== ==========
Cheers,
Brett
I have three files:
mail.htm - a html email form
mymailer.asp - an asp mail handler script
enquiry_sent.htm - the redirection page after the mail form is sent
I want to be able to hit submit button in mail.htm, and have an email go to bca1977@hotmail.com and for the user to then be redirected to enquirey_sent.htm
Here is the script for the two key pages:
==========================
mail.htm - only inlcluded relevant code - page also has other html
==========================
<table cellspacing="2" cellpadding="2" border="0" align="center">
<form name="CFForm_1" action="mymailer.asp" method="post">
<input type="hidden" name="mail_categoryID" value="1">
<input type="hidden" name="mail_recipient" value="bca1977@hotmail.com
<input type="hidden" name="mail_subject" value="Batukarang Lembongan Request">
<input type="hidden" name="mail_redirect" value="/enquiry_sent.htm">
<tr>
<td colspan="2" align="center" valign="top" height="35">Please complete all fields marked with *
</td>
</tr>
<tr>
<td align="right" valign="top">Request Details :
</td>
<td><textarea name="request_details" cols="40" rows="6" wrap="virtual"></textarea>
<tr>
<td align="right">Check in date :
</td>
<td><input name="check_in" id="check_in" type="text" size="20"/></td></tr>
<tr>
<td align="right">Check out date :
</td>
<td><input name="check_out" id="check_out" type="text" size="20"/></td></tr>
<tr>
<td align="right">Room Type :
</td>
<td><select name="room_type">
<option value="">--- Please Select ---
<option value="Superior">Superior
<option value="Deluxe" selected>Deluxe
<option value="Romantic Room">Romantic Room
<option value="Family / 3 Bedded">Family / 3 Bedded
<option value="Superior Suite">Superior Suite
<option value="Deluxe Suite">Deluxe Suite
<option value="Bintang Bali Suite">Bintang Bali Suite
<option value="Special Needs">Special Needs
</select>
</td>
</tr>
<tr>
<td align="right">Number of rooms :
</td>
<td><input name="number_of_rooms" id="number_of_rooms" type="text" size="3" />
</td>
</tr>
<tr>
<td align="right">How many adults : </td>
<td><input name="how_many_adults" id="how_many_adults" type="text" size="3" />
</td>
</tr>
<tr>
<td align="right">How many children :
</td>
<td><input name="How_many_children" id="How_many_children" type="text" size="3" />
</td>
</tr>
<tr>
<td align="right">Airport Pick Up :
</td>
<td><input type="radio" name="airport_pick_up" value="Yes" style="background:">Yes
<input type="radio" name="airport_pick_up" value="No" style="background:" checked >No
</td>
</tr>
<tr>
<td align="right">Name * :
</td>
<td><input name="name" id="name" type="text" size="40" />
</td>
</tr>
<tr>
<td align="right">Email Address * :
</td>
<td><input name="email" id="email" type="text" size="40" />
</td>
</tr>
<tr>
<td align="right">City :
</td>
<td><input name="city" id="city" type="text" size="40" />
</td>
</tr>
<tr>
<td align="right">Country :
</td>
<td><input name="country" id="country" type="text" size="40"/>
</td>
</tr>
<tr>
<td align="right">Phone :
</td>
<td><input name="phone" id="phone" type="text" size="40" />
</td>
</tr>
<tr>
<td align="right">Fax :
</td>
<td><input name="fax" id="fax" type="text" size="40" />
</td>
</tr>
<tr>
<td align="right" valign="top">Comments :
</td>
<td><textarea name="comments" cols="40" rows="6" wrap="virtual"></textarea>
</td>
</tr>
<tr>
<td>
</td>
<td height="40" valign="bottom">
<input type="submit" value=" Submit " class="bt">
<input type="reset" value=" Clear " class="bt">
<input type="button" value=" Back " class="bt" onclick="javascript:histor
<!-- The back button won't work cause you don't have the javascript-->
</td>
</tr>
</form>
</table>
==========================
mymailer.asp - please note this page has no other script - no html headers or anything
==========================
<%
dim Body as string
body="New Reservation:" & vbcrlf
body=body & "Category ID=" & request.form("mail_categor
body=body & "Customer Name: " & request.form("name") & vbcrlf
'... continue building your email layout here
body=body & request.form("request_deta
Set myMail=CreateObject("CDO.M
myMail.Subject=request.for
myMail.From=request.form("
myMail.To=request.form("ma
myMail.TextBody=body
myMail.Send
set myMail=nothing
response.redirect("/reques
%>
==========================
Cheers,
Brett
So what's wrong with it? Looking fine so far. The only pitfalls I can forsee right now are the wrong redirect URL (which I assume you can change easily), or more rarely: CDO.Message not working properly or SMTP not configured to send to the hotmail address.
ASKER
When hitting the submit button it goes to the following URL (the asp file):
http://www.batukaranglembongan.com/mymailer.asp
with the following error:
HTTP 405 error Method Not Allowed
The website cannot display the page
HTTP 405
Most likely cause:
The website has a programming error.
And no email is sent to bca1977@hotmail.com
Cheers,
Brett
http://www.batukaranglembongan.com/mymailer.asp
with the following error:
HTTP 405 error Method Not Allowed
The website cannot display the page
HTTP 405
Most likely cause:
The website has a programming error.
And no email is sent to bca1977@hotmail.com
Cheers,
Brett
ASKER
Hi,
I just found out even though i was told the server supported ASP it actually does not.
I know no PHP, can you help me convert mymailer.asp to PHP or Perl?
Cheers,
Brett
I just found out even though i was told the server supported ASP it actually does not.
I know no PHP, can you help me convert mymailer.asp to PHP or Perl?
Cheers,
Brett
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
now we're talking!!!
so i have to write the folliwng for each object in the form yeah?
"Category ID=" . $_POST["mail_categoryID"] . "\n" .
Cheers,
Brett
so i have to write the folliwng for each object in the form yeah?
"Category ID=" . $_POST["mail_categoryID"] . "\n" .
Cheers,
Brett
Bingo, thats right. Also you'll need to save it to have a PHP extension (mymailer.php), and have your form HTML point to it appropriately.
ASKER
PS> i changed this to the following and it didn't work:
header("Location: /enquiry_sent.htm); // you might want to change this
header("Location: /enquiry_sent.htm); // you might want to change this
you forgot the last quotes mark " after .htm :)
ASKER
ah, thanks...
also, just checking - should this be in there twice?
$_POST["request_details"];
cheers,
Brett:
<?php
$body="New Reservation:\n" .
"Category ID=" . $_POST["mail_categoryID"] . "\n" .
"Request Details: " . $_POST["request_details"] . "\n" .
"Check in date: " . $_POST["check_in"] . "\n" .
"Check out date: " . $_POST["check_out"] . "\n" .
"Room Type: " . $_POST["room_type"] . "\n" .
"Number of rooms: " . $_POST["number_of_rooms"] . "\n" .
"How many adults: " . $_POST["how_many_adults"] . "\n" .
"How many children: " . $_POST["How_many_children" ] . "\n" .
"Airport Pick Up: " . $_POST["airport_pick_up"] . "\n" .
"Name: " . $_POST["name"] . "\n" .
"Email Address: " . $_POST["email"] . "\n" .
"City: " . $_POST["city"] . "\n" .
"Country: " . $_POST["country"] . "\n" .
"Phone: " . $_POST["phone"] . "\n" .
"Fax: " . $_POST["fax"] . "\n" .
"Comments: " . $_POST["comments"] . "\n" .
$_POST["request_details"];
mail($_POST["mail_recipien t"], $_POST["mail_subject"], $body, "From: " . $_POST["mail_recipient"]);
header("Location: /enquiry_sent.htm");
?>
also, just checking - should this be in there twice?
$_POST["request_details"];
cheers,
Brett:
<?php
$body="New Reservation:\n" .
"Category ID=" . $_POST["mail_categoryID"] . "\n" .
"Request Details: " . $_POST["request_details"] . "\n" .
"Check in date: " . $_POST["check_in"] . "\n" .
"Check out date: " . $_POST["check_out"] . "\n" .
"Room Type: " . $_POST["room_type"] . "\n" .
"Number of rooms: " . $_POST["number_of_rooms"] . "\n" .
"How many adults: " . $_POST["how_many_adults"] . "\n" .
"How many children: " . $_POST["How_many_children"
"Airport Pick Up: " . $_POST["airport_pick_up"] . "\n" .
"Name: " . $_POST["name"] . "\n" .
"Email Address: " . $_POST["email"] . "\n" .
"City: " . $_POST["city"] . "\n" .
"Country: " . $_POST["country"] . "\n" .
"Phone: " . $_POST["phone"] . "\n" .
"Fax: " . $_POST["fax"] . "\n" .
"Comments: " . $_POST["comments"] . "\n" .
$_POST["request_details"];
mail($_POST["mail_recipien
header("Location: /enquiry_sent.htm");
?>
ASKER
redirection still doesn't work?
ASKER
is the html file right?
<input type="hidden" name="mail_redirect" value="/enquiry_sent.htm">
<input type="hidden" name="mail_redirect" value="/enquiry_sent.htm">
ASKER
I already removed the extra $_POST["request_details"]
Cheers,
Brett
Cheers,
Brett
hehe nope it doesn't have to, sorry.
redirection doesn't work? what reponse do you get?
kind of a blind guess here, but try putting "ob_start();" before the mail() line.
redirection doesn't work? what reponse do you get?
kind of a blind guess here, but try putting "ob_start();" before the mail() line.
ASKER
it just loads the blank mymailer.php page
you mean like this?
"ob_start();"
mail($_POST["mail_recipien t"], $_POST["mail_subject"], $body, "From: " . $_POST["mail_recipient"]);
header("Location: /enquiry_sent.htm");
didn't work...
you mean like this?
"ob_start();"
mail($_POST["mail_recipien
header("Location: /enquiry_sent.htm");
didn't work...
ASKER
aahggg....
for some reason the emails aren't coming through anymore....
should the PHP code be in the head or body tags?
for some reason the emails aren't coming through anymore....
should the PHP code be in the head or body tags?
well, forget the ob_start for now but the PHP should be in its own file.
// start of mailer.php
<?php
$body="New Reservation:\n" .
"Category ID=" . $_POST["mail_categoryID"] . "\n" .
"Customer Name: " . $_POST["name"] . "\n" .
// ... continue building your email layout here .
$_POST["request_details"];
mail($_POST["mail_recipien t"], $_POST["mail_subject"], $body, "From: " . $_POST["mail_recipient"]);
header("Location: /request-info/index.cfm?co nf=ok"); // you might want to change this
?>
// end of mailer.php
// start of mailer.php
<?php
$body="New Reservation:\n" .
"Category ID=" . $_POST["mail_categoryID"] . "\n" .
"Customer Name: " . $_POST["name"] . "\n" .
// ... continue building your email layout here .
$_POST["request_details"];
mail($_POST["mail_recipien
header("Location: /request-info/index.cfm?co
?>
// end of mailer.php
ASKER
ok, will try that, thanks.
i'm also liasing with the host to ensure they have their end covered.
cheers,
Brett
i'm also liasing with the host to ensure they have their end covered.
cheers,
Brett
ASKER
Hi I have a new php page im using instead of the mail.htm page called contactus.php
Weve managed to get it to send emails (although i had to disable the name and email checking by changing all false values to true) yet the text values do not come through... only the headings do.
Hope someone can help.
Cheers!
Brett
=====================
<?PHP
session_start();
if ($_SERVER['HTTP_REFERER'] != "http://$_SERVER[HTTP_HOST]$_SERVER[PHP_S ELF]") {
unset($_SESSION['request_d etails']);
unset($_SESSION['check_in' ]);
unset($_SESSION['check_out ']);
unset($_SESSION['room_type ']);
unset($_SESSION['number_of _rooms']);
unset($_SESSION['how_many_ adults']);
unset($_SESSION['how_many_ children'] );
unset($_SESSION['airport_p ick_up']);
unset($_SESSION['name']);
unset($_SESSION['name_bg'] );
unset($_SESSION['name_vali d']);
unset($_SESSION['email']);
unset($_SESSION['email_bg' ]);
unset($_SESSION['email_val id']);
unset($_SESSION['city']);
unset($_SESSION['country'] );
unset($_SESSION['phone']);
unset($_SESSION['fax']);
unset($_SESSION['comments' ]);
}
if (!isset($_SESSION['emailCo unt'])) {
unset($_SESSION['emailCoun t']);
$_SESSION['emailCount'] = (int) 0;
}
if (!isset($_SESSION['emailSt ep'])) {
unset($_SESSION['emailStep ']);
$_SESSION['emailStep'] = (int) 1;
}
if (!isset($_SESSION['request _details'] )) {
unset($_SESSION['request_d etails']);
$_SESSION['request_details '] = (string) '';
} else {
if (isset($_POST['request_det ails'])) {
$_SESSION['request_details '] = strip_tags($_POST['request _details'] );
}
}
if (!isset($_SESSION['check_i n'])) {
unset($_SESSION['check_in' ]);
$_SESSION['check_in'] = (string) '';
} else {
if (isset($_POST['check_in']) ) {
$_SESSION['check_in'] = strip_tags($_POST['check_i n']);
}
}
if (!isset($_SESSION['check_o ut'])) {
unset($_SESSION['check_out ']);
$_SESSION['check_out'] = (string) '';
} else {
if (isset($_POST['check_out'] )) {
$_SESSION['check_out'] = strip_tags($_POST['check_o ut']);
}
}
if (!isset($_SESSION['room_ty pe'])) {
unset($_SESSION['room_type ']);
$_SESSION['room_type'] = (string) '';
} else {
if (isset($_POST['room_type'] )) {
$_SESSION['room_type'] = strip_tags($_POST['room_ty pe']);
}
}
if (!isset($_SESSION['number_ of_rooms'] )) {
unset($_SESSION['number_of _rooms']);
$_SESSION['number_of_rooms '] = (string) '';
} else {
if (isset($_POST['number_of_r ooms'])) {
$_SESSION['number_of_rooms '] = strip_tags($_POST['number_ of_rooms'] );
}
}
if (!isset($_SESSION['how_man y_adults'] )) {
unset($_SESSION['how_many_ adults']);
$_SESSION['how_many_adults '] = (string) '';
} else {
if (isset($_POST['how_many_ad ults'])) {
$_SESSION['how_many_adults '] = strip_tags($_POST['how_man y_adults'] );
}
}
if (!isset($_SESSION['how_man y_children '])) {
unset($_SESSION['how_many_ children'] );
$_SESSION['how_many_childr en'] = (string) '';
} else {
if (isset($_POST['how_many_ch ildren'])) {
$_SESSION['how_many_childr en'] = strip_tags($_POST['how_man y_children ']);
}
}
if (!isset($_SESSION['airport _pick_up'] )) {
unset($_SESSION['airport_p ick_up']);
$_SESSION['airport_pick_up '] = (string) '';
} else {
if (isset($_POST['airport_pic k_up'])) {
$_SESSION['airport_pick_up '] = strip_tags($_POST['airport _pick_up'] );
}
}
if (!isset($_SESSION['name']) ) {
unset($_SESSION['name']);
unset($_SESSION['name_bg'] );
unset($_SESSION['name_vali d']);
$_SESSION['name'] = (string) '';
$_SESSION['name_bg'] = (string) '#FFFFFF';
$_SESSION['name_valid'] = (bool) true;
} else {
if (isset($_POST['name'])) {
$_SESSION['name'] = strip_tags($_POST['name']) ;
}
}
if (!isset($_SESSION['email'] )) {
unset($_SESSION['email']);
unset($_SESSION['email_bg' ]);
unset($_SESSION['email_val id']);
$_SESSION['email'] = (string) '';
$_SESSION['email_bg'] = (string) '#FFFFFF';
$_SESSION['email_valid'] = (bool) true;
} else {
if (isset($_POST['email'])) {
$_SESSION['email'] = strip_tags($_POST['email'] );
}
}
if (!isset($_SESSION['city']) ) {
unset($_SESSION['city']);
$_SESSION['city'] = (string) '';
} else {
if (isset($_POST['city'])) {
$_SESSION['city'] = strip_tags($_POST['city']) ;
}
}
if (!isset($_SESSION['country '])) {
unset($_SESSION['country'] );
$_SESSION['country'] = (string) '';
} else {
if (isset($_POST['country'])) {
$_SESSION['country'] = strip_tags($_POST['country ']);
}
}
if (!isset($_SESSION['phone'] )) {
unset($_SESSION['phone']);
$_SESSION['phone'] = (string) '';
} else {
if (isset($_POST['phone'])) {
$_SESSION['phone'] = strip_tags($_POST['phone'] );
}
}
if (!isset($_SESSION['fax'])) {
unset($_SESSION['fax']);
$_SESSION['fax'] = (string) '';
} else {
if (isset($_POST['fax'])) {
$_SESSION['fax'] = strip_tags($_POST['fax']);
}
}
if (!isset($_SESSION['comment s'])) {
unset($_SESSION['comments' ]);
$_SESSION['comments'] = (string) '';
} else {
if (isset($_POST['comments']) ) {
$_SESSION['comments'] = strip_tags($_POST['comment s']);
}
}
$emailErrorCount = (int) 0;
$emailErrors = array();
function name($emailErrorCount, $emailErrors) {
global $emailErrorCount;
global $emailErrors;
if (empty($_SESSION['name'])) {
$emailErrors[$emailErrorCo unt] = "First Name is missing.";
$emailErrorCount++;
$_SESSION['name_bg'] = '#FF0000';
$_SESSION['name_valid'] = true;
return;
}
if (preg_match("/([0-9])/", $_SESSION['name'])) {
$emailErrors[$emailErrorCo unt] = "First name can only contain letters.";
$emailErrorCount++;
$_SESSION['name_bg'] = '#FF0000';
$_SESSION['name_valid'] = true;
return;
}
$_SESSION['name_bg'] = '#FFFFFF';
$_SESSION['name_valid'] = true;
return;
}
function email($emailErrorCount, $emailErrors) {
global $emailErrorCount;
global $emailErrors;
$CheckDNS = 1;
if (empty($_SESSION['email']) ) {
$emailErrors[$emailErrorCo unt] = "Email Address is missing.";
$emailErrorCount++;
$_SESSION['email_bg'] = '#FF0000';
$_SESSION['email_valid'] = true;
return;
}
if (!preg_match("/^([a-zA-Z0- 9_-])+@([a -zA-Z0-9_- ])+(\.[a-z A-Z0-9_-]+ )+/", $_SESSION['email'])) {
$emailErrors[$emailErrorCo unt] = "Email Address submitted is not valid.";
$emailErrorCount++;
$_SESSION['email_bg'] = '#FF0000';
$_SESSION['email_valid'] = true;
return;
}
if ($CheckDNS == '1') {
$UserName = '';
$MailDomain = '';
list ($UserName, $MailDomain) = split("@", $_SESSION['email']);
if (!checkdnsrr($MailDomain, "MX")) {
$emailErrors[$emailErrorCo unt] = "Email Address submitted is not valid.";
$emailErrorCount++;
$_SESSION['email_bg'] = '#FF0000';
$_SESSION['email_valid'] = true;
return;
}
unset($UserName);
unset($MailDomain);
}
$_SESSION['email_bg'] = '#FFFFFF';
$_SESSION['email_valid'] = true;
return;
}
function emailSubmit() {
if ($_SESSION['name_valid'] == true && $_SESSION['email_valid'] == true) {
$email = (array) '';
if ($_SESSION['emailCount'] < 50) {
$email['mailTo'] = 'info@batukaranglembongan. com';
$email['mailSubject'] = 'Brett Rocks';
$email['mailText'] = "Request Details: $_SESSION[request_details] \r\nCheck In: $_SESSION[check_in]\r\nChe ck Out: $_SESSION[check_out]\r\nRo om Type: $_SESSION[room_type]\r\nNu mber Of Rooms: $_SESSION[number_of_rooms] \r\nHow Many Adults: $_SESSION[how_many_adults] \r\nHow Many Children: $_SESSION[how_many_childre n]\r\nAirp ort Pick Up: $_SESSION[airport_pick_up] \r\nName: $_SESSION[name]\r\nEmail: $_SESSION[email]\r\nCity: $_SESSION[city]\r\nCountry : $_SESSION[country]\r\nPhon e: $_SESSION[phone]\r\nFax: $_SESSION[fax]\r\nComments : $_SESSION[comments]";
$email['fromPerson'] = "$_SESSION[email]";
$email['fromEmail'] = 'info@batukaranglembongan. com';
mail("$email[mailTo]", "$email[mailSubject]", "$email[mailText]", "From: $email[fromPerson] <$email[fromEmail]>\r\nRep ly-To: $email[fromPerson] <$email[fromEmail]>\r\n" );
$_SESSION['emailCount']++;
$_SESSION['emailStep'] = 2;
}
}
return;
}
function emailReset() {
unset($_SESSION['request_d etails']);
unset($_SESSION['check_in' ]);
unset($_SESSION['check_out ']);
unset($_SESSION['room_type ']);
unset($_SESSION['number_of _rooms']);
unset($_SESSION['how_many_ adults']);
unset($_SESSION['how_many_ children'] );
unset($_SESSION['airport_p ick_up']);
unset($_SESSION['name']);
unset($_SESSION['name_bg'] );
unset($_SESSION['name_vali d']);
unset($_SESSION['email']);
unset($_SESSION['email_bg' ]);
unset($_SESSION['email_val id']);
unset($_SESSION['city']);
unset($_SESSION['country'] );
unset($_SESSION['phone']);
unset($_SESSION['fax']);
unset($_SESSION['comments' ]);
}
if (!empty($_POST['Submit'])) {
name($emailErrorCount, $emailErrors);
email($emailErrorCount, $emailErrors);
emailSubmit();
}
if ($_SESSION['emailStep'] == '1') {
echo('<table cellspacing="2" cellpadding="2" border="0" align="center">');
echo('<form name="CFForm_1" action="'."$_SERVER[PHP_SE LF]".'" method="post" onsubmit="return _CF_checkCFForm_1(this)">' );
echo('<input type="hidden" name="Submit" value="1">');
echo('<tr>');
echo('<td colspan="2" align="center" valign="top" height="35">Please complete all fields marked with *');
if (count($emailErrors) != 0) {
echo('<div class="text2"><font color="#FF0000">The Following Errors Occured</font></div>');
}
foreach($emailErrors as $emailErrors) {
echo('<li><font color="#FF0000">'."$emailE rrors".'</ font></li> ');
}
echo('</td>');
echo('</tr>');
echo('<tr>');
echo('<td align="right" valign="top">Request Details :');
echo('</td>');
echo('<td><textarea name="request_details" cols="40" rows="6" wrap="virtual"></textarea> </td></tr> ');
echo('<tr>');
echo('<td align="right">Check in date :');
echo('</td>');
echo('<td><input name="check_in" id="check_in" type="text" size="20"/></td></tr>');
echo('<tr>');
echo('<td align="right">Check out date :');
echo('</td>');
echo('<td><input name="check_out" id="check_out" type="text" size="20"/></td></tr>');
echo('<tr>');
echo('<td align="right">Room Type :');
echo('</td>');
echo('<td><select name="room_type">');
echo('<option value="">--- Please Select ---');
echo('<option value="Superior">Superior' );
echo('<option value="Deluxe" selected>Deluxe');
echo('<option value="Romantic Room">Romantic Room');
echo('<option value="Family / 3 Bedded">Family / 3 Bedded');
echo('<option value="Superior Suite">Superior Suite');
echo('<option value="Deluxe Suite">Deluxe Suite');
echo('<option value="Bintang Bali Suite">Bintang Bali Suite');
echo('<option value="Special Needs">Special Needs');
echo('</select>');
echo('</td>');
echo('</tr>');
echo('<tr>');
echo('<td align="right">Number of rooms :');
echo('</td>');
echo('<td><input name="number_of_rooms" id="number_of_rooms" type="text" size="3" value="'."$_SESSION[number _of_rooms] ".'"/>');
echo('</td>');
echo('</tr>');
echo('<tr>');
echo('<td align="right">How many adults :</td>');
echo('<td><input name="how_many_adults" id="how_many_adults" type="text" size="3" value="'."$_SESSION[how_ma ny_adults] ".'"/>');
echo('</td>');
echo('</tr>');
echo('<tr>');
echo('<td align="right">How many children :');
echo('</td>');
echo('<td><input name="how_many_children" id="how_many_children" type="text" size="3" value="'."$_SESSION[how_ma ny_childre n]".'"/>') ;
echo('</td>');
echo('</tr>');
echo('<tr>');
echo('<td align="right">Airport Pick Up :');
echo('</td>');
echo('<td><input type="radio" name="airport_pick_up" value="Yes" style="background:">Yes');
echo('<input type="radio" name="airport_pick_up" value="No" style="background:" checked >No');
echo('</td>');
echo('</tr>');
echo('<tr>');
echo('<td align="right">Name * :');
echo('</td>');
echo('<td><input name="name" id="name" type="text" size="40" value="'."$_SESSION[name]" .'"/>');
echo('</td>');
echo('</tr>');
echo('<tr>');
echo('<td align="right">Email Address * :');
echo('</td>');
echo('<td><input name="email" id="email" type="text" size="40" value="'."$_SESSION[email] ".'"/>');
echo('</td>');
echo('</tr>');
echo('<tr>');
echo('<td align="right">City :');
echo('</td>');
echo('<td><input name="city" id="city" type="text" size="40" value="'."$_SESSION[city]" .'"/>');
echo('</td>');
echo('</tr>');
echo('<tr>');
echo('<td align="right">Country :');
echo('</td>');
echo('<td><input name="country" id="country" type="text" size="40" value="'."$_SESSION[countr y]".'"/>') ;
echo('</td>');
echo('</tr>');
echo('<tr>');
echo('<td align="right">Phone :');
echo('</td>');
echo('<td><input name="phone" id="phone" type="text" size="40" value="'."$_SESSION[phone] ".'"/>');
echo('</td>');
echo('</tr>');
echo('<tr>');
echo('<td align="right">Fax :');
echo('</td>');
echo('<td><input name="fax" id="fax" type="text" size="40" value="'."$_SESSION[fax]". '"/>');
echo('</td>');
echo('</tr>');
echo('<tr>');
echo('<td align="right" valign="top">Comments :');
echo('</td>');
echo('<td><textarea name="comments" cols="40" rows="6" wrap="virtual">'."$_SESSIO N[comments ]".'</text area>');
echo('</td>');
echo('</tr>');
echo('<tr>');
echo('<td>');
echo('</td>');
echo('<td height="40" valign="bottom">');
echo('<input type="submit" value=" Submit " class="bt">');
echo('<input type="reset" value=" Clear " class="bt">');
echo('<input type="button" value=" Back " class="bt" onclick="javascript:histor y.back(1); ">');
echo('<!-- The back button won\'t work cause you don\'t have javascript enabled-->');
echo('</td>');
echo('</tr>');
echo('</form>');
echo('</table>');
} elseif ($_SESSION['emailStep'] == '2') {
echo("Your mail has been sent!");
emailReset();
}
?>
Weve managed to get it to send emails (although i had to disable the name and email checking by changing all false values to true) yet the text values do not come through... only the headings do.
Hope someone can help.
Cheers!
Brett
=====================
<?PHP
session_start();
if ($_SERVER['HTTP_REFERER'] != "http://$_SERVER[HTTP_HOST]$_SERVER[PHP_S
unset($_SESSION['request_d
unset($_SESSION['check_in'
unset($_SESSION['check_out
unset($_SESSION['room_type
unset($_SESSION['number_of
unset($_SESSION['how_many_
unset($_SESSION['how_many_
unset($_SESSION['airport_p
unset($_SESSION['name']);
unset($_SESSION['name_bg']
unset($_SESSION['name_vali
unset($_SESSION['email']);
unset($_SESSION['email_bg'
unset($_SESSION['email_val
unset($_SESSION['city']);
unset($_SESSION['country']
unset($_SESSION['phone']);
unset($_SESSION['fax']);
unset($_SESSION['comments'
}
if (!isset($_SESSION['emailCo
unset($_SESSION['emailCoun
$_SESSION['emailCount'] = (int) 0;
}
if (!isset($_SESSION['emailSt
unset($_SESSION['emailStep
$_SESSION['emailStep'] = (int) 1;
}
if (!isset($_SESSION['request
unset($_SESSION['request_d
$_SESSION['request_details
} else {
if (isset($_POST['request_det
$_SESSION['request_details
}
}
if (!isset($_SESSION['check_i
unset($_SESSION['check_in'
$_SESSION['check_in'] = (string) '';
} else {
if (isset($_POST['check_in'])
$_SESSION['check_in'] = strip_tags($_POST['check_i
}
}
if (!isset($_SESSION['check_o
unset($_SESSION['check_out
$_SESSION['check_out'] = (string) '';
} else {
if (isset($_POST['check_out']
$_SESSION['check_out'] = strip_tags($_POST['check_o
}
}
if (!isset($_SESSION['room_ty
unset($_SESSION['room_type
$_SESSION['room_type'] = (string) '';
} else {
if (isset($_POST['room_type']
$_SESSION['room_type'] = strip_tags($_POST['room_ty
}
}
if (!isset($_SESSION['number_
unset($_SESSION['number_of
$_SESSION['number_of_rooms
} else {
if (isset($_POST['number_of_r
$_SESSION['number_of_rooms
}
}
if (!isset($_SESSION['how_man
unset($_SESSION['how_many_
$_SESSION['how_many_adults
} else {
if (isset($_POST['how_many_ad
$_SESSION['how_many_adults
}
}
if (!isset($_SESSION['how_man
unset($_SESSION['how_many_
$_SESSION['how_many_childr
} else {
if (isset($_POST['how_many_ch
$_SESSION['how_many_childr
}
}
if (!isset($_SESSION['airport
unset($_SESSION['airport_p
$_SESSION['airport_pick_up
} else {
if (isset($_POST['airport_pic
$_SESSION['airport_pick_up
}
}
if (!isset($_SESSION['name'])
unset($_SESSION['name']);
unset($_SESSION['name_bg']
unset($_SESSION['name_vali
$_SESSION['name'] = (string) '';
$_SESSION['name_bg'] = (string) '#FFFFFF';
$_SESSION['name_valid'] = (bool) true;
} else {
if (isset($_POST['name'])) {
$_SESSION['name'] = strip_tags($_POST['name'])
}
}
if (!isset($_SESSION['email']
unset($_SESSION['email']);
unset($_SESSION['email_bg'
unset($_SESSION['email_val
$_SESSION['email'] = (string) '';
$_SESSION['email_bg'] = (string) '#FFFFFF';
$_SESSION['email_valid'] = (bool) true;
} else {
if (isset($_POST['email'])) {
$_SESSION['email'] = strip_tags($_POST['email']
}
}
if (!isset($_SESSION['city'])
unset($_SESSION['city']);
$_SESSION['city'] = (string) '';
} else {
if (isset($_POST['city'])) {
$_SESSION['city'] = strip_tags($_POST['city'])
}
}
if (!isset($_SESSION['country
unset($_SESSION['country']
$_SESSION['country'] = (string) '';
} else {
if (isset($_POST['country']))
$_SESSION['country'] = strip_tags($_POST['country
}
}
if (!isset($_SESSION['phone']
unset($_SESSION['phone']);
$_SESSION['phone'] = (string) '';
} else {
if (isset($_POST['phone'])) {
$_SESSION['phone'] = strip_tags($_POST['phone']
}
}
if (!isset($_SESSION['fax']))
unset($_SESSION['fax']);
$_SESSION['fax'] = (string) '';
} else {
if (isset($_POST['fax'])) {
$_SESSION['fax'] = strip_tags($_POST['fax']);
}
}
if (!isset($_SESSION['comment
unset($_SESSION['comments'
$_SESSION['comments'] = (string) '';
} else {
if (isset($_POST['comments'])
$_SESSION['comments'] = strip_tags($_POST['comment
}
}
$emailErrorCount = (int) 0;
$emailErrors = array();
function name($emailErrorCount, $emailErrors) {
global $emailErrorCount;
global $emailErrors;
if (empty($_SESSION['name']))
$emailErrors[$emailErrorCo
$emailErrorCount++;
$_SESSION['name_bg'] = '#FF0000';
$_SESSION['name_valid'] = true;
return;
}
if (preg_match("/([0-9])/", $_SESSION['name'])) {
$emailErrors[$emailErrorCo
$emailErrorCount++;
$_SESSION['name_bg'] = '#FF0000';
$_SESSION['name_valid'] = true;
return;
}
$_SESSION['name_bg'] = '#FFFFFF';
$_SESSION['name_valid'] = true;
return;
}
function email($emailErrorCount, $emailErrors) {
global $emailErrorCount;
global $emailErrors;
$CheckDNS = 1;
if (empty($_SESSION['email'])
$emailErrors[$emailErrorCo
$emailErrorCount++;
$_SESSION['email_bg'] = '#FF0000';
$_SESSION['email_valid'] = true;
return;
}
if (!preg_match("/^([a-zA-Z0-
$emailErrors[$emailErrorCo
$emailErrorCount++;
$_SESSION['email_bg'] = '#FF0000';
$_SESSION['email_valid'] = true;
return;
}
if ($CheckDNS == '1') {
$UserName = '';
$MailDomain = '';
list ($UserName, $MailDomain) = split("@", $_SESSION['email']);
if (!checkdnsrr($MailDomain, "MX")) {
$emailErrors[$emailErrorCo
$emailErrorCount++;
$_SESSION['email_bg'] = '#FF0000';
$_SESSION['email_valid'] = true;
return;
}
unset($UserName);
unset($MailDomain);
}
$_SESSION['email_bg'] = '#FFFFFF';
$_SESSION['email_valid'] = true;
return;
}
function emailSubmit() {
if ($_SESSION['name_valid'] == true && $_SESSION['email_valid'] == true) {
$email = (array) '';
if ($_SESSION['emailCount'] < 50) {
$email['mailTo'] = 'info@batukaranglembongan.
$email['mailSubject'] = 'Brett Rocks';
$email['mailText'] = "Request Details: $_SESSION[request_details]
$email['fromPerson'] = "$_SESSION[email]";
$email['fromEmail'] = 'info@batukaranglembongan.
mail("$email[mailTo]", "$email[mailSubject]", "$email[mailText]", "From: $email[fromPerson] <$email[fromEmail]>\r\nRep
$_SESSION['emailCount']++;
$_SESSION['emailStep'] = 2;
}
}
return;
}
function emailReset() {
unset($_SESSION['request_d
unset($_SESSION['check_in'
unset($_SESSION['check_out
unset($_SESSION['room_type
unset($_SESSION['number_of
unset($_SESSION['how_many_
unset($_SESSION['how_many_
unset($_SESSION['airport_p
unset($_SESSION['name']);
unset($_SESSION['name_bg']
unset($_SESSION['name_vali
unset($_SESSION['email']);
unset($_SESSION['email_bg'
unset($_SESSION['email_val
unset($_SESSION['city']);
unset($_SESSION['country']
unset($_SESSION['phone']);
unset($_SESSION['fax']);
unset($_SESSION['comments'
}
if (!empty($_POST['Submit']))
name($emailErrorCount, $emailErrors);
email($emailErrorCount, $emailErrors);
emailSubmit();
}
if ($_SESSION['emailStep'] == '1') {
echo('<table cellspacing="2" cellpadding="2" border="0" align="center">');
echo('<form name="CFForm_1" action="'."$_SERVER[PHP_SE
echo('<input type="hidden" name="Submit" value="1">');
echo('<tr>');
echo('<td colspan="2" align="center" valign="top" height="35">Please complete all fields marked with *');
if (count($emailErrors) != 0) {
echo('<div class="text2"><font color="#FF0000">The Following Errors Occured</font></div>');
}
foreach($emailErrors as $emailErrors) {
echo('<li><font color="#FF0000">'."$emailE
}
echo('</td>');
echo('</tr>');
echo('<tr>');
echo('<td align="right" valign="top">Request Details :');
echo('</td>');
echo('<td><textarea name="request_details" cols="40" rows="6" wrap="virtual"></textarea>
echo('<tr>');
echo('<td align="right">Check in date :');
echo('</td>');
echo('<td><input name="check_in" id="check_in" type="text" size="20"/></td></tr>');
echo('<tr>');
echo('<td align="right">Check out date :');
echo('</td>');
echo('<td><input name="check_out" id="check_out" type="text" size="20"/></td></tr>');
echo('<tr>');
echo('<td align="right">Room Type :');
echo('</td>');
echo('<td><select name="room_type">');
echo('<option value="">--- Please Select ---');
echo('<option value="Superior">Superior'
echo('<option value="Deluxe" selected>Deluxe');
echo('<option value="Romantic Room">Romantic Room');
echo('<option value="Family / 3 Bedded">Family / 3 Bedded');
echo('<option value="Superior Suite">Superior Suite');
echo('<option value="Deluxe Suite">Deluxe Suite');
echo('<option value="Bintang Bali Suite">Bintang Bali Suite');
echo('<option value="Special Needs">Special Needs');
echo('</select>');
echo('</td>');
echo('</tr>');
echo('<tr>');
echo('<td align="right">Number of rooms :');
echo('</td>');
echo('<td><input name="number_of_rooms" id="number_of_rooms" type="text" size="3" value="'."$_SESSION[number
echo('</td>');
echo('</tr>');
echo('<tr>');
echo('<td align="right">How many adults :</td>');
echo('<td><input name="how_many_adults" id="how_many_adults" type="text" size="3" value="'."$_SESSION[how_ma
echo('</td>');
echo('</tr>');
echo('<tr>');
echo('<td align="right">How many children :');
echo('</td>');
echo('<td><input name="how_many_children" id="how_many_children" type="text" size="3" value="'."$_SESSION[how_ma
echo('</td>');
echo('</tr>');
echo('<tr>');
echo('<td align="right">Airport Pick Up :');
echo('</td>');
echo('<td><input type="radio" name="airport_pick_up" value="Yes" style="background:">Yes');
echo('<input type="radio" name="airport_pick_up" value="No" style="background:" checked >No');
echo('</td>');
echo('</tr>');
echo('<tr>');
echo('<td align="right">Name * :');
echo('</td>');
echo('<td><input name="name" id="name" type="text" size="40" value="'."$_SESSION[name]"
echo('</td>');
echo('</tr>');
echo('<tr>');
echo('<td align="right">Email Address * :');
echo('</td>');
echo('<td><input name="email" id="email" type="text" size="40" value="'."$_SESSION[email]
echo('</td>');
echo('</tr>');
echo('<tr>');
echo('<td align="right">City :');
echo('</td>');
echo('<td><input name="city" id="city" type="text" size="40" value="'."$_SESSION[city]"
echo('</td>');
echo('</tr>');
echo('<tr>');
echo('<td align="right">Country :');
echo('</td>');
echo('<td><input name="country" id="country" type="text" size="40" value="'."$_SESSION[countr
echo('</td>');
echo('</tr>');
echo('<tr>');
echo('<td align="right">Phone :');
echo('</td>');
echo('<td><input name="phone" id="phone" type="text" size="40" value="'."$_SESSION[phone]
echo('</td>');
echo('</tr>');
echo('<tr>');
echo('<td align="right">Fax :');
echo('</td>');
echo('<td><input name="fax" id="fax" type="text" size="40" value="'."$_SESSION[fax]".
echo('</td>');
echo('</tr>');
echo('<tr>');
echo('<td align="right" valign="top">Comments :');
echo('</td>');
echo('<td><textarea name="comments" cols="40" rows="6" wrap="virtual">'."$_SESSIO
echo('</td>');
echo('</tr>');
echo('<tr>');
echo('<td>');
echo('</td>');
echo('<td height="40" valign="bottom">');
echo('<input type="submit" value=" Submit " class="bt">');
echo('<input type="reset" value=" Clear " class="bt">');
echo('<input type="button" value=" Back " class="bt" onclick="javascript:histor
echo('<!-- The back button won\'t work cause you don\'t have javascript enabled-->');
echo('</td>');
echo('</tr>');
echo('</form>');
echo('</table>');
} elseif ($_SESSION['emailStep'] == '2') {
echo("Your mail has been sent!");
emailReset();
}
?>
ASKER
Please close this question.
Thanks
Thanks