setting up form to send results to email

Status
Not open for further replies.

icomedsupply

New Member
Messages
7
Reaction score
0
Points
0
Well I've been looking and I've been getting some conflicting/confusing answers. So simply put, how do i set up my html form code so that when the user clicks submit it sends their input/data to my email address?

Here is the code:
Code:
<form action="process.php" method="POST"> 
  <fieldset> <label
 for="fname">First name:</label>
  <input value="" size="20"
 id="fname" type="text"><br>
  <label for="lname">Last
Name:</label> <input
 value="" size="20" id="lname" type="text"><br>
  <label for="faddress">Address:</label>
  <input value="" size="20"
 id="faddress" type="text"><br>
  <label for="laddress">Address2:</label>
  <input value="" size="20"
 id="laddress" type="text"><br>
  <label for="city">City:</label>
  <input value="" size="20"
 id="city" type="text"><br>
  <label for="state">State:</label>
  <input value="" size="20"
 id="state" type="text"><br>
  <label for="country">Country:</label>
  <input value="" size="20"
 id="country" type="text"><br>
  <label for="zip">Zip/Postal
Code:</label> <input
 value="" size="20" id="zip" type="text"><br>
  <label for="phone">Phone:</label>
  <input value="" size="20"
 id="phone" type="text"><br>
  <label for="fax">Fax:</label>
  <input value="" size="20"
 id="fax" type="text"><br>
  <label for="mobile">Mobile:</label>
  <input value="" size="20"
 id="mobile" type="text"><br>
  <label for="email">Email
Address:</label> <input
 value="" size="20" id="email" type="text"><br>
  <label for="best time">Best
Time to Contact:</label>
  <select name="best time">
  <option value="morning">Morning</option>
  <option value="afternoon">Afternoon</option>
  <option value="evening"
 selected="selected">Evening</option>
  </select>
  <br>
  <br>
  <label for="preferred">Preferred
Method of Contact:</label>
  <select name="preferred">
  <option value="phone">Phone</option>
  <option value="fax">Fax</option>
  <option value="email"
 selected="selected">Email</option>
  </select>
  <br>
  <br>
  <label for="comments">Comments,Questions,Special
Interests:</label>
  <textarea rows="5" cols="25"></textarea>
  <input value="Submit"
 class="submit-btn" name="Submit" type="submit">
  </fieldset>
</form>
help would be greatly appreciated. I joined this webhosting service because at my old webhost you had to pay for php and sendmail to be activated but I heard that here it's included free.
 

loveispoison

Banned
Messages
323
Reaction score
0
Points
0
is this a contact page i mean were user can send you email or something else please explain?
 
Last edited:

nbwebmaster

New Member
Messages
36
Reaction score
0
Points
0
You cannot achieve this with HTML alone. You must put the mail() function in your process.php page. I do not know all of the details of how to do this yet, as I am currently working on a site myself.
 

Smith6612

I ate all of the x10Pizza
Community Support
Messages
6,518
Reaction score
48
Points
48
If you're using PHP, just use the mail() function or you can use SMTP/Localhost. If you're using Python/PERL scripts, you can use localhost/SMTP on the script to send the mail. Is this what you're asking for?
 

te.creative

New Member
Messages
11
Reaction score
0
Points
0
create your process.php file and put this in (just replace with the values that you use on your form):

Code:
<?php 
$submit = $HTTP_POST_VARS['submit'];
$name = $HTTP_POST_VARS['name'];
$company = $HTTP_POST_VARS['company'];
$address = $HTTP_POST_VARS['address'];
$phone = $HTTP_POST_VARS['phone'];
$email = $HTTP_POST_VARS['email'];
$message = $HTTP_POST_VARS['message'];
?>

            <font face="Arial" size="3">
Thank you for your comments! <br><br>

We will get back to you as soon as possible
<br><br>
</font>
<?php
if ($submit) {
	  $datetime = date("YmdHis");
		$mess = "<table border='0' width='500' bgcolor='#C0C0C0' cellspacing='1'>
    <tr>
      <td bgcolor='#FFFFFF' align='center'><font face='Arial' size='2'><b>Name</b></font></td>
      <td bgcolor='#FFFFFF'><font face='Arial' size='2'>$name</font></td>
    </tr>
    <tr>
      <td bgcolor='#FFFFFF' align='center'><font face='Arial' size='2'><b>Company</b></font></td>
      <td bgcolor='#FFFFFF'><font face='Arial' size='2'>$company</font></td>
    </tr>
    <tr>
      <td bgcolor='#FFFFFF' align='center'><font face='Arial' size='2'><b>Address</b></font></td>
      <td bgcolor='#FFFFFF'><font face='Arial' size='2'>$address</font></td>
    </tr>
    <tr>
      <td bgcolor='#FFFFFF' align='center'><font face='Arial' size='2'><b>Phone</b></font></td>
      <td bgcolor='#FFFFFF'><font face='Arial' size='2'>$phone</font></td>
    </tr>
    <tr>
      <td bgcolor='#FFFFFF' align='center'><font face='Arial' size='2'><b>Email</b></font></td>
      <td bgcolor='#FFFFFF'><font face='Arial' size='2'>$email</font></td>
    </tr>
    <tr>
      <td bgcolor='#FFFFFF' align='center'><font face='Arial' size='2'><b>Message</b></font></td>
      <td bgcolor='#FFFFFF'><font face='Arial' size='2'>$message</font></td>
    </tr>
  </table>";
	   mail("yourname@yourdomain.com","Guestbook form",$mess,"From: $name<$email>\nReply-To: $email\nContent-Type: text/html; charset=ISO-8859-1\nX-Mailer: PHP/" . phpversion());

}
?>

i've been using it for some time now, and i've been too lazy to clean it up since it works just fine for me. hope this helps.
 

icomedsupply

New Member
Messages
7
Reaction score
0
Points
0
oh hey thanks! I'll try this. This won't replace my original form though right?

[EDIT]

I tried the code on my site, but it didn't work. I got this error:
Parse error: syntax error, unexpected T_STRING in /home/icocare/public_html/process.php on line 13


here's the code i used:

Code:
<?php 
$fname = $HTTP_POST_VARS['fname'];
$lname = $HTTP_POST_VARS['lname'];
$faddress = $HTTP_POST_VARS['faddress'];
$laddress = $HTTP_POST_VARS['laddress'];
$state = $HTTP_POST_VARS['state'];
$country = $HTTP_POST_VARS['country'];
$city = $HTTP_POST_VARS['city'];
$zip = $HTTP_POST_VARS['zip'];
$phone = $HTTP_POST_VARS['phone'];
$fax = $HTTP_POST_VARS['fax'];
$mobile = $HTTP_POST_VARS['mobile'];
$best time = $HTTP_POST_VARS['best_time'];
$preferred = $HTTP_POST_VARS['preferred'];
$comments = $HTTP_POST_VARS['comments'];
?>

            <font face="Arial" size="3">
Thank you for your comments! <br><br>

We will get back to you as soon as possible
<br><br>
</font>
<?php
if ($submit) {
	  $datetime = date("YmdHis");
		$mess = "<table border='0' width='500' bgcolor='#C0C0C0' cellspacing='1'>
    <tr>
      <td bgcolor='#FFFFFF' align='center'><font face='Arial' size='2'><b>First Name</b></font></td>
      <td bgcolor='#FFFFFF'><font face='Arial' size='2'>$fname</font></td>
    </tr>
    <tr>
      <td bgcolor='#FFFFFF' align='center'><font face='Arial' size='2'><b>Last Name</b></font></td>
      <td bgcolor='#FFFFFF'><font face='Arial' size='2'>klnamef</font></td>
    </tr>
    <tr>
      <td bgcolor='#FFFFFF' align='center'><font face='Arial' size='2'><b>Address</b></font></td>
      <td bgcolor='#FFFFFF'><font face='Arial' size='2'>$faddress</font></td>
    </tr>
    <tr>
      <td bgcolor='#FFFFFF' align='center'><font face='Arial' size='2'><b>Address2</b></font></td>
      <td bgcolor='#FFFFFF'><font face='Arial' size='2'>$laddress</font></td>
    </tr>
    <tr>
      <td bgcolor='#FFFFFF' align='center'><font face='Arial' size='2'><b>State</b></font></td>
      <td bgcolor='#FFFFFF'><font face='Arial' size='2'>$state</font></td>
    </tr>
    <tr>
      <td bgcolor='#FFFFFF' align='center'><font face='Arial' size='2'><b>Country</b></font></td>
      <td bgcolor='#FFFFFF'><font face='Arial' size='2'>$country</font></td>
    </tr>
    <tr>
      <td bgcolor='#FFFFFF' align='center'><font face='Arial' size='2'><b>City</b></font></td>
      <td bgcolor='#FFFFFF'><font face='Arial' size='2'>$city</font></td>
    </tr>
   <tr>
      <td bgcolor='#FFFFFF' align='center'><font face='Arial' size='2'><b>Zip</b></font></td>
      <td bgcolor='#FFFFFF'><font face='Arial' size='2'>$zip</font></td>
    </tr>
   <tr>
      <td bgcolor='#FFFFFF' align='center'><font face='Arial' size='2'><b>Phone</b></font></td>
      <td bgcolor='#FFFFFF'><font face='Arial' size='2'>$phone</font></td>
    </tr>
   <tr>
      <td bgcolor='#FFFFFF' align='center'><font face='Arial' size='2'><b>Fax</b></font></td>
      <td bgcolor='#FFFFFF'><font face='Arial' size='2'>$fax</font></td>
    </tr>
   <tr>
      <td bgcolor='#FFFFFF' align='center'><font face='Arial' size='2'><b>Mobile</b></font></td>
      <td bgcolor='#FFFFFF'><font face='Arial' size='2'>$mobile</font></td>
    </tr>
   <tr>
      <td bgcolor='#FFFFFF' align='center'><font face='Arial' size='2'><b>Email</b></font></td>
      <td bgcolor='#FFFFFF'><font face='Arial' size='2'>$email</font></td>
    </tr>
   <tr>
      <td bgcolor='#FFFFFF' align='center'><font face='Arial' size='2'><b>Best Time</b></font></td>
      <td bgcolor='#FFFFFF'><font face='Arial' size='2'>$best time</font></td>
    </tr>
   <tr>
      <td bgcolor='#FFFFFF' align='center'><font face='Arial' size='2'><b>Preferred</b></font></td>
      <td bgcolor='#FFFFFF'><font face='Arial' size='2'>$preferred</font></td>
    </tr>
   <tr>
      <td bgcolor='#FFFFFF' align='center'><font face='Arial' size='2'><b>Comments</b></font></td>
      <td bgcolor='#FFFFFF'><font face='Arial' size='2'>$comments</font></td>
    </tr>
  </table>";
	   mail("formdata@icocare.pcriot.com","Web Form Data",$mess,"From: $name<$email>\nReply-To: $email\nContent-Type: text/html; charset=ISO-8859-1\nX-Mailer: PHP/" . phpversion());

}
?>
 
Last edited:

arlenemc

New Member
Messages
13
Reaction score
0
Points
0
i think there should be no space between best and time, so make it $besttime or $best_time
 
Status
Not open for further replies.
Top