Link to home
Start Free TrialLog in
Avatar of brettanderson77
brettanderson77Flag for Australia

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:history.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_categoryID") & vbcrlf
body=body & "Customer Name: " & request.form("name") & vbcrlf
'... continue building your email layout here
body=body & request.form("request_details")

Set myMail=CreateObject("CDO.Message")
myMail.Subject=request.form("mail_subject")
myMail.From=request.form("mail_recipient")
myMail.To=request.form("mail_recipient")
myMail.TextBody=body
myMail.Send
set myMail=nothing
response.redirect("/request-info/index.cfm?conf=ok")
%>

==================================================================

Cheers,
Brett
Avatar of aescnt
aescnt

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.
Avatar of brettanderson77

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
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
ASKER CERTIFIED SOLUTION
Avatar of aescnt
aescnt

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
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.
PS> i changed this to the following and it didn't work:

header("Location: /enquiry_sent.htm); // you might want to change this
you forgot the last quotes mark " after .htm :)
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_recipient"], $_POST["mail_subject"], $body, "From: " . $_POST["mail_recipient"]);
header("Location: /enquiry_sent.htm");
?>
redirection still doesn't work?
is the html file right?

          <input type="hidden" name="mail_redirect" value="/enquiry_sent.htm">
I already removed the extra $_POST["request_details"]
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.
it just loads the blank mymailer.php page

you mean like this?

"ob_start();"
mail($_POST["mail_recipient"], $_POST["mail_subject"], $body, "From: " . $_POST["mail_recipient"]);
header("Location: /enquiry_sent.htm");

didn't work...
aahggg....

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_recipient"], $_POST["mail_subject"], $body, "From: " . $_POST["mail_recipient"]);
header("Location: /request-info/index.cfm?conf=ok"); // you might want to change this
?>
// end of mailer.php
ok, will try that, thanks.

i'm also liasing with the host to ensure they have their end covered.

cheers,
Brett
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_SELF]") {
          unset($_SESSION['request_details']);
          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_pick_up']);
          unset($_SESSION['name']);
          unset($_SESSION['name_bg']);
          unset($_SESSION['name_valid']);
          unset($_SESSION['email']);
          unset($_SESSION['email_bg']);
          unset($_SESSION['email_valid']);
          unset($_SESSION['city']);
          unset($_SESSION['country']);
          unset($_SESSION['phone']);
          unset($_SESSION['fax']);
          unset($_SESSION['comments']);
     }

     if (!isset($_SESSION['emailCount'])) {
          unset($_SESSION['emailCount']);
          $_SESSION['emailCount'] = (int) 0;
     }
     if (!isset($_SESSION['emailStep'])) {
          unset($_SESSION['emailStep']);
          $_SESSION['emailStep'] = (int) 1;
     }


     if (!isset($_SESSION['request_details'])) {
          unset($_SESSION['request_details']);
          $_SESSION['request_details'] = (string) '';
     } else {
          if (isset($_POST['request_details'])) {
               $_SESSION['request_details'] = strip_tags($_POST['request_details']);
          }
     }
     if (!isset($_SESSION['check_in'])) {
          unset($_SESSION['check_in']);
          $_SESSION['check_in'] = (string) '';
     } else {
          if (isset($_POST['check_in'])) {
               $_SESSION['check_in'] = strip_tags($_POST['check_in']);
          }
     }
     if (!isset($_SESSION['check_out'])) {
          unset($_SESSION['check_out']);
          $_SESSION['check_out'] = (string) '';
     } else {
          if (isset($_POST['check_out'])) {
               $_SESSION['check_out'] = strip_tags($_POST['check_out']);
          }
     }
     if (!isset($_SESSION['room_type'])) {
          unset($_SESSION['room_type']);
          $_SESSION['room_type'] = (string) '';
     } else {
          if (isset($_POST['room_type'])) {
               $_SESSION['room_type'] = strip_tags($_POST['room_type']);
          }
     }
     if (!isset($_SESSION['number_of_rooms'])) {
          unset($_SESSION['number_of_rooms']);
          $_SESSION['number_of_rooms'] = (string) '';
     } else {
          if (isset($_POST['number_of_rooms'])) {
               $_SESSION['number_of_rooms'] = strip_tags($_POST['number_of_rooms']);
          }
     }
     if (!isset($_SESSION['how_many_adults'])) {
          unset($_SESSION['how_many_adults']);
          $_SESSION['how_many_adults'] = (string) '';
     } else {
          if (isset($_POST['how_many_adults'])) {
               $_SESSION['how_many_adults'] = strip_tags($_POST['how_many_adults']);
          }
     }
     if (!isset($_SESSION['how_many_children'])) {
          unset($_SESSION['how_many_children']);
          $_SESSION['how_many_children'] = (string) '';
     } else {
          if (isset($_POST['how_many_children'])) {
               $_SESSION['how_many_children'] = strip_tags($_POST['how_many_children']);
          }
     }
     if (!isset($_SESSION['airport_pick_up'])) {
          unset($_SESSION['airport_pick_up']);
          $_SESSION['airport_pick_up'] = (string) '';
     } else {
          if (isset($_POST['airport_pick_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_valid']);
          $_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_valid']);
          $_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['comments'])) {
          unset($_SESSION['comments']);
          $_SESSION['comments'] = (string) '';
     } else {
          if (isset($_POST['comments'])) {
               $_SESSION['comments'] = strip_tags($_POST['comments']);
          }
     }



     $emailErrorCount = (int) 0;
     $emailErrors = array();

     function name($emailErrorCount, $emailErrors) {
          global $emailErrorCount;
          global $emailErrors;
          if (empty($_SESSION['name'])) {
               $emailErrors[$emailErrorCount] = "First Name is missing.";
               $emailErrorCount++;
               $_SESSION['name_bg'] = '#FF0000';
               $_SESSION['name_valid'] = true;
               return;
          }
          if (preg_match("/([0-9])/", $_SESSION['name'])) {
               $emailErrors[$emailErrorCount] = "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[$emailErrorCount] = "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-zA-Z0-9_-]+)+/", $_SESSION['email'])) {
               $emailErrors[$emailErrorCount] = "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[$emailErrorCount] = "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\nCheck Out: $_SESSION[check_out]\r\nRoom Type: $_SESSION[room_type]\r\nNumber Of Rooms: $_SESSION[number_of_rooms]\r\nHow Many Adults: $_SESSION[how_many_adults]\r\nHow Many Children: $_SESSION[how_many_children]\r\nAirport Pick Up: $_SESSION[airport_pick_up]\r\nName: $_SESSION[name]\r\nEmail: $_SESSION[email]\r\nCity: $_SESSION[city]\r\nCountry: $_SESSION[country]\r\nPhone: $_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\nReply-To: $email[fromPerson] <$email[fromEmail]>\r\n" );

                    $_SESSION['emailCount']++;
                    $_SESSION['emailStep'] = 2;
               }
          }
          return;
     }
     
     function emailReset() {
          unset($_SESSION['request_details']);
          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_pick_up']);
          unset($_SESSION['name']);
          unset($_SESSION['name_bg']);
          unset($_SESSION['name_valid']);
          unset($_SESSION['email']);
          unset($_SESSION['email_bg']);
          unset($_SESSION['email_valid']);
          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_SELF]".'" 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">'."$emailErrors".'</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_many_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_many_children]".'"/>');
          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[country]".'"/>');
          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">'."$_SESSION[comments]".'</textarea>');
          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:history.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();
     }
?>
Please close this question.
Thanks