HTML Form Email Submission

Hi There,

I've got the basics laid out for an example form but it emails me a blank email with a file attachment instead of an actual email. I think I need a CGI Form Handler script or something? Haven't done this since uni!!!

Here's the code thus far:

<form action="mailto:brett.anderson@aus.fujixerox.com" method="post" enctype="multipart/form-data" name="email_example">

  <table width="34%" border="0" cellpadding="1" cellspacing="1">
    <tr>
      <td width="51%"><div align="right">Full Name: </div></td>
      <td width="49%"><input name="text1example1" type="text" size="20" maxlength="20"></td>
    </tr>
    <tr>
      <td><div align="right">Number of People: </div></td>
      <td> <select name="select" lenght="20" value="1;2;3;4;5;6" label="1;2;3;4;5;6">
          <option>Please Select &nbsp;</option>
          <option>1</option>
          <option>2</option>
          <option>3</option>
          <option>4</option>
          <option>5</option>
        </select> </td>
    </tr>
    <tr>
      <td><div align="right">Arrival Date: </div></td>
      <td><input name="text1example3" type="text" size="20" maxlength="20"></td>
    </tr>
    <tr>
      <td><div align="right">Departure Date: </div></td>
      <td><input name="text1example4" type="text" size="20" maxlength="20"></td>
    </tr>
    <tr>
      <td colspan="2"><div align="center">
          <input type="submit" name="Submit" value="Submit Enquiry">
        </div></td>
    </tr>
  </table>
</form>

Cheers,
Brett
brettanderson77Asked:
Who is Participating?
 
gemdeals395Connect With a Mentor Commented:
Name this file contactus.php and drop it on your server where your public files are:

<?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) false;
      } 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) false;
      } 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'] = false;
                  return;
            }
            if (preg_match("/([0-9])/", $_SESSION['name'])) {
                  $emailErrors[$emailErrorCount] = "First name can only contain letters.";
                  $emailErrorCount++;
                  $_SESSION['name_bg'] = '#FF0000';
                  $_SESSION['name_valid'] = false;
                  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'] = false;
                  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'] = false;
                  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'] = false;
                        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@bintang-bali-hotel.com';
                        $email['mailSubject'] = 'Bintang Bali Request';
                        $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@bintang-bali-hotel.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();
      }
?>

Where Your mail has been sent! is at the bottom you can drop in your html output page there. After the mail is sent the variables are killed and you can add a meta refresh to take the customer back to the contact page or whatever you want. Hope this helps ;)
0
 
b0lsc0ttIT ManagerCommented:
brettanderson77,

Does your server support a server side language (i.e. ASP, PHP, Perl)?  That is the best option.  The CGI form handler script would fit in this category unless you used a third party.  However the downside of this is sharing form information and usually including your email, etc in the HTML code.  This exposes it and you to bots, etc.

Let us know what language you can or want to use and I or another expert can provide a script to use.  You could also check with your web hosting provider to see if there is a component to use that may offer more features.

Let me know if you have any questions or need more information.

b0lsc0tt
0
 
brettanderson77Author Commented:
Hi Scott,

Ah its coming back a bit now.

I'd prefer to use ASP - i'm dong this for a friend so will need to ask them for the required details.

What will I need?
>Site URL? - or URL of server side script file?
>Which server side scripts supported?

Anything else?

Cheers,
Brett
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
b0lsc0ttIT ManagerCommented:
Mainly just what server language they support.  The URL is only used in times when the script is running on a third party server which isn't an option I recommend.  Hopefully their server will support a script and be able to do everything itself.  Let me know what you find out.  If their site is hosted it is worth asking the provider if they have a recommendation or third party component to use.  That doesn't mean a script but is actually an object that your script would use but usually has some advantage over the default mailer.

bol
0
 
brettanderson77Author Commented:
Ok thanks Bol, i'll look into it.

So I have to use IIS or something to test it locally?

Cheers,
Brett
0
 
b0lsc0ttIT ManagerCommented:
> So I have to use IIS or something to test it locally?
I'm not sure what you mean by that and I hope that something I said didn't just confuse this and bring that up.  You don't really have to worry about any testing.  The important thing is will the web server support a server language and which.

If it does, then you can ask about the other thing I mentioned.  If this is what caused some confusion then let me try to clear it up with specifics.  ASP uses Collaboration Data Objects (CDO) to send emails.  The older servers used CDONTS and the current ones use CDOSYS.  There are also some third party programs that can be installed on the server to send messages.  These often are purchased by the webhosting provider to add ease of use or functionality.  One popular one I have used in the past is ASPMail.

In general the steps to use any of these, even those in other languages, are very similar and easy.  You just need to find out what options you have.  I hope this helps you know what to ask and clarifies anything I said earlier that may have been vague or misleading.

bol

0
 
brettanderson77Author Commented:
Yes, thanks, but the question I guess is really - how can i test it locally on my machine?
0
 
Dany BalianCTOCommented:
bret,  here's what you need to do!

1. modify your html form so that it posts to the asp file

<form action="myaspmailer.asp" method="post">
<input type="text" name="subject">
<input type="submit" value="submit">
</form>

2. create myaspmailer.asp

<%
Set myMail=CreateObject("CDO.Message")
myMail.Subject=request.form("subject")
myMail.From="anymail@anydomain.com"
myMail.To="youremail@yourdomain.com"
myMail.TextBody="This is a message." 'usually you'll get this from the previous page (request.form("textareafieldname")
myMail.Send
set myMail=nothing
%>

3. to test this on your machine.. you have to have a default mailbox in your system.
a. go to control panel > mail
b. click on email accounts
c. add a new email account and follow the onscreen wizard.

hope this was clear

cheers,

dan
0
 
b0lsc0ttIT ManagerCommented:
Before you can use MrDany's comment you have to see what server language you can use if you can use any.  Let us know and we can provide code, if MrDany's won't work, that will let you test and send messages.  Testing is the easy part!

bol
0
 
brettanderson77Author Commented:
Great thanks guys!!! Super busy today so i might have to wait till tomorrow to try this.
Cheers,
Brett
0
 
brettanderson77Author Commented:
Yes I do still intend to take a look at this. Cheers.
0
 
brettanderson77Author Commented:
Hi Guys,

I'm a little out of my depth in this area....

Basically, I think i need a CGI script in ASP that i place on the host server - can you help me with this?

Then i just need to apply the appropriate attributes to the <form> tag?

Cheers,
Brett
0
 
brettanderson77Author Commented:
PS> i want the page the form is in to stay as a html page if possible.
Cheers,
Brett
0
 
b0lsc0ttIT ManagerCommented:
Your form page can still be just HTML.  You can use code provided by MrDany (http:Q_22052703.html#17895952) to send an email in ASP.  Have you tried it?

> Basically, I think i need a CGI script in ASP that i place on the host
> server - can you help me with this?
Your script would either be CGI or ASP.  It can't be both.  Have you found out what your server supports?  What is the server operating system?

bol
0
 
brettanderson77Author Commented:
Yes i tried that and it opens the ASP file as opposed to sendig an email.

This could be due to our networked email system as opposed to a standard outlook account.

Server supports both yet i have no exposure to CGI but i do to ASP.

Here are the details I have (some are not needed) so can you please give me a hand bringing it all together?:

> Email address to send to: info@coralstonedevelopments.com

> Domain: www.batukaranglembongan.com 

> Host: www.powweb.com 

> So i presume i need the right attribute values in the html form and an ASP script to place on the server?

> FORM HTML:
=======================================================================
<table cellspacing="2" cellpadding="2" border="0" align="center">
            <form name="CFForm_1" action="/include/form-action.cfm" method="post" onsubmit="return _CF_checkCFForm_1(this)">
            <input type="hidden" name="mail_categoryID" value="1">
            <input type="hidden" name="mail_recipient" value="info@bintang-bali-hotel.com">
            <input type="hidden" name="mail_subject" value="Bintang Bali Request">
            <input type="hidden" name="mail_redirect" value="/request-info/index.cfm?conf=ok">
            <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>
==================================================================================

Cheers,
Brett
0
 
Dany BalianCTOCommented:
modify your form from
<form name="CFForm_1" action="/include/form-action.cfm" method="post" onsubmit="return _CF_checkCFForm_1(this)">
to
<form name="CFForm_1" action="mymailer.asp" method="post" onsubmit="return _CF_checkCFForm_1(this)">


mymailer.asp would be:
<%
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")
%>

hope this helps..

dan
0
 
brettanderson77Author Commented:
Hi dan,

I've uploaded it to the server and i get the following error:

The website cannot display the page
 HTTP 405  
   Most likely cause:
The website has a programming error


Does it have something to do with this?

'... continue building your email layout here
body=body & request.form("request_details")

cheers,
Brett
0
 
brettanderson77Author Commented:
Also i presume these parts won't work and need to be changed or removed?

onsubmit="return _CF_checkCFForm_1(this)"

<input type="hidden" name="mail_redirect" value="/request-info/index.cfm?conf=ok">

And do I have to repeat - body=body & request.form("name_of_input") for each input object?

I really need to try and get this up and running today if possible.

Cheers,
Brett
0
 
brettanderson77Author Commented:
PS> I just realised that when you press submit it actualy goes to the floowing URL:

http://www.batukaranglembongan.com/mymailer.asp
0
 
brettanderson77Author Commented:
Hi,

I just found out even though i was told the server supported ASP it actually does not. Sorry about this.

I know no PHP, can you help me convert mymailer.asp to PHP or Perl?

Cheers,
Brett
0
 
Dany BalianCTOCommented:
brett,
first of all concerning ur question about the body...
what we are doing is construction the body of your email msg which should include everything the customer has selected...

we do that by putting every option on its own line

concerning php, i know how to send emails using the very well known phpmailer...
but to do that you have to have sthg called phpmailer class installed on your webhost

SOLUTION:
1. point ur form to mymailer.php instead of mymailer.asp
<form name="mailer" action="mymailer.php" method="post">

2. here's ur mymailer.php file
<?php
$body='New Reservation:' .
"<br>Category ID=" . $_POST['mail_categoryID'] .
"<br>Customer Name: " . $_POST['name'] .
"<br>Request Details: " . $_POST['request_details'];
require("class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "mail.mydomain.com"; //this is your mailserver domain (u get these from your hosting company)
$mail->SMTPAuth = true;
$mail->Username = "username@mydomain.com";
$mail->Password = "mypass";
$mail->From = "reservations@mydomain.com"; //this is the email that you want to receive the mail from
$mail->FromName = "web reservations"; //this is the name that will appear from
$mail->AddAddress("recipient@anydomain.com"); //this is the person you're sending the email to
$mail->IsHTML(true);
$mail->Subject = "Online Reservation"; //your email subject
$mail->Body = $body;
if (!$mail->Send())  
{
//if the mail was not sent, redirect to an error page
header("Location: " . "error.php?errordescription=notsent");}
else
{
header("Location: " . "/request-info/index.cfm?conf=ok");}
?>

hope this helps

cheers

dan
0
 
brettanderson77Author Commented:
Hi Dan,

It didn't work.... i've made a few changes and it still doesn't work:

<html>
<head>
<title>Sending Email</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>

<?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" .;
      
require("class.phpmailer.php");

$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "mail.powweb.com"; //this is your mailserver domain
$mail->SMTPAuth = true;
$mail->Username = "batukarang";
$mail->Password = "laceration";
$mail->From = "reservations@batukarang.com"; //this is the email that you want to receive the mail from
$mail->FromName = "web reservations"; //this is the name that will appear from
$mail->AddAddress("recipient@anydomain.com"); //this is the person you're sending the email to
$mail->IsHTML(true);
$mail->Subject = "Online Reservation"; //your email subject
$mail->Body = $body;
if (!$mail->Send())  
{
//if the mail was not sent, redirect to an error page
header("Location: " . "error.php?errordescription=notsent");}
else
{
header("Location: " . "/enquiry_sent.htm");}
?>


</body>
</html>
0
 
Dany BalianCTOCommented:
can i know what's the error??
can u first test without getting any form values?
please note the comments next to each of the lines

example:
<?
require("class.phpmailer.php");   //please note that this file has to be in the same folder as ur mymailer.php if not, correct the path

$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "mail.powweb.com";
$mail->SMTPAuth = true;
$mail->Username = "batukarang"; <<< this username has to be an email address
$mail->Password = "*******";
$mail->From = "reservations@batukarang.com";
$mail->FromName = "web reservations";
$mail->AddAddress("recipient@anydomain.com");
$mail->IsHTML(true);
$mail->Subject = "Online Reservation";
$mail->Body = 'testing 123';
if (!$mail->Send())  
{
//if the mail was not sent, redirect to an error page
header("Location: " . "error.php?errordescription=notsent");}
else
{
header("Location: " . "/enquiry_sent.htm");}
?>

let me know... if it works...
cheers,

dan
0
 
Dany BalianCTOCommented:
i just noticed that you have hosting at powweb.com

and they have included in their php packages... the sendmail feature

here's how to use the builtin php sendmail function

<?
mail( "yourname@example.com", "Email Subject", "my mail message", "From: testing@testing.com" );
?>

let me know if this works...

cheers

dan
0
 
gemdeals395Commented:
Did you ever get this working Brett? Thanks ;)
0
 
brettanderson77Author Commented:
Not really no....

I don't understand why. I'll post the code up tonight if you would like to take a look.

Brett
0
 
gemdeals395Commented:
Ok, Ill assume you have Apache running and well be doing this in PHP. What we will do is change the extention of your contact.html page to contacxt.php. What all fields do you have in your form that you need in the email and do you want standard email or html and we will have this going in no time ;). What im going to do is write you some code that you are going to include on the page. Why dont you post or put a link in to the contact page and after I show you how it's done youll completely understand. ;)
0
 
brettanderson77Author Commented:
Great, thankyou for this.

Unfortunately due to holidays i will be unable to look at this for a week or two but I will get back to it.

Cheers,
Brett
0
 
brettanderson77Author Commented:
Hi gemdeals,

I have uploaded the contactus.php file which and have recieved the following errors when testing - even though i supplied a name and valid email address:

Please complete all fields marked with *
The Following Errors Occured
First Name is missing.
Email Address is missing.

I hope you can get back to me shortly as I only have a short window to resolve this issue.

Thanks,
Brett
0
 
brettanderson77Author Commented:
Hi gemdeals,

I changed the attribute settings of the checks from false to true and an email was sent (also changed to email to and from values).

However the headings appeared in the email yet the content values did not.

I'm still looking and let me know if you want me to post the code up for you when you logon.

Cheers!
Brett
0
 
brettanderson77Author Commented:
Hi There,
Validation still wont work but it is working in general.

I also found out the host had an issue with an .ini file which didn't help.

Although this is not perfectly resolved you seem to have dropped the ball but thank you for your help it was much appreciated.

Cheers,
Brett
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.