Jump to content

Email Contact Us Form


Hello_LOL

Recommended Posts

Hi everyone I'm new to PHP and on this forum, so please excuse my ignorance. I would think what I'm looking for has already been covered on here somewhere, but I'm not even sure I'm calling it the right name when searching, so I couldn't find anything understandable to me on the mater.

 

I'm trying to create a basic Email Contact Form with many fields:

Organization name: 

Contact name:

Address:

Phone:

Email:

and so on, but I can't get things to work.

I have used this layout which did work, but soon as I added more to it it broke.

http://www.thesitewizard.com/archive/feedbackphp.shtml

 

Here's what i have for the php:

 

<?php

  $Organization_name = $_REQUEST['Organization_name'] ;

  $Contact_name = $_REQUEST['Contact_name'] ;

  $Address = $_REQUEST['Address'] ;

  $Phone = $_REQUEST['Phone'] ;

  $Email = $_REQUEST['Email'] ;

  $Approximate_number_of_employees = $_REQUEST['Approximate_number_of_employees'] ;

  $Are_you_currently_insured = $_REQUEST['Are_you_currently_insured'] ;

  $If_yes_with_whom = $_REQUEST['If_yes_with_whom'] ;

  $What_is_the_best_time_of_day_you_can_be_reached = $_REQUEST['What_is_the_best_time_of_day_you_can_be_reached'] ;

  $Message = $_REQUEST['Message'] ;

 

  mail( "[email protected]", "Quote Form for Organization & Group", $Organization_name, $Contact_name, $Address, $Phone, $Email, $Approximate_number_of_employees, $Are_you_currently_insured, $If_yes_with_whom, $What_is_the_best_time_of_day_you_can_be_reached, $Message, "From: $Email" );

  header( "Location: http://www.mysite.com/thankyou.html" );

?>

 

and this is the html:

 

<form method="post" action="sendmail2.php">

<table width="489" border="0" align="center" cellspacing="10">

  <tr>

    <td width="205" align="right">Organization name:</td>

    <td width="250"><span class="input"><input name="Organization name" type="text" size="40" maxlength="40" />

    </span></td>

  </tr>

  <tr>

    <td align="right">Contact name:</td>

    <td><input name="Contact_name" type="text" size="40" maxlength="40" /></td>

  </tr>

  <tr>

    <td align="right">Address:</td>

    <td><input name="Address" type="text" size="40" maxlength="40" /></td>

  </tr>

  <tr>

    <td align="right" >Phone:</label></td>

    <td ><input name="Phone" type="text" size="40" maxlength="40" /></td>

  </tr>

  <tr>

    <td align="right">Email:</td>

    <td><input name="Email" type="text" size="40" maxlength="40" /></td>

  </tr>

  <tr>

    <td align="right">Approximate number of employees:</td>

    <td><input name="Approximate_number_of employees" type="text" size="40" maxlength="40" /></td>

  </tr>

  <tr>

    <td valign="top" align="right">Are you currently insured?</td>

    <td><input name="Are_you_currently_insured" type="text" size="40" maxlength="40" /></td>

  </tr>

  <tr>

    <td valign="top" align="right">If  yes, with whom?</td>

    <td><input name="If_yes_with_whom" type="text" size="40" maxlength="40" /></td>

  </tr>

  <tr>

    <td valign="top" align="right">What is the best time of day you can be reached?</td>

    <td><input name="What_is_the_best_time_of_day_you_can_be_reached" type="text" size="40" maxlength="40" /></td>

  </tr>

  <tr>

    <td valign="top" align="right">Message:</td>

    <td><textarea name="Message" rows="15" cols="40"></textarea></td>

  </tr>

  <tr>

    <td> </td>

    <td> </td>

  </tr>

  <tr>

    <td> </td>

    <td><input type="submit" value="Request a Quote"/> <INPUT TYPE="reset" VALUE="Clear"></td>

  </tr>

</table>

<label></label>

</form>

 

 

Any help would be appreciated.

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/157638-email-contact-us-form/
Share on other sites

the mail() feature doesn't have that many parameters. Looks like you're stuffing the variables in the mail header. This causes serious security issues, and won't show up in the body of the email.

 

http://us2.php.net/manual/en/function.mail.php

 

Basically, you need to reduce that function to the top three: to, subject, message. All of the "stuff" should be inside the message parameter. You can do this like such:

 

$combined_message="Org Name: $Organization_name\r\nContact Name: $Contact_name\r\nAddress: $Address\r\nPhone: $Phone\r\nEmail: $Email\r\nApprox Employees: $Approximate_number_of_employees\r\nCurrently Insured: $Are_you_currently_insured\r\nWith Whom:$If_yes_with_whom\r\nBest Time to Reach: $What_is_the_best_time_of_day_you_can_be_reached\r\nMessage: $Message;
mail( "[email protected]", "Quote Form for Organization & Group",$combined_message);

 

I also eliminated the "from: $email" header - which is a really bad security loophole. It won't take spam bots long to find your form and exploit it for their own ends.

i get this message when I click submit:

Parse error: syntax error, unexpected T_STRING in sendmail2.php on line 14

 

I think pasted your code into the right place  :-\

 

<?php
  $Organization_name = $_REQUEST['Organization_name'] ;
  $Contact_name = $_REQUEST['Contact_name'] ;
  $Address = $_REQUEST['Address'] ;
  $Phone = $_REQUEST['Phone'] ;
  $Email = $_REQUEST['Email'] ;
  $Approximate_number_of_employees = $_REQUEST['Approximate_number_of_employees'] ;
  $Are_you_currently_insured = $_REQUEST['Are_you_currently_insured'] ;
  $If_yes_with_whom = $_REQUEST['If_yes_with_whom'] ;
  $What_is_the_best_time_of_day_you_can_be_reached = $_REQUEST['What_is_the_best_time_of_day_you_can_be_reached'] ;
  $Message = $_REQUEST['Message'] ;

  mail( $combined_message="Org Name: $Organization_name\r\nContact Name: $Contact_name\r\nAddress: $Address\r\nPhone: $Phone\r\nEmail: $Email\r\nApprox Employees: $Approximate_number_of_employees\r\nCurrently Insured: $Are_you_currently_insured\r\nWith Whom:$If_yes_with_whom\r\nBest Time to Reach: $What_is_the_best_time_of_day_you_can_be_reached\r\nMessage: $Message;
mail( [email protected]", "Quote Form for Organization & Group",$combined_message);
  header( "Location:thankyou.html" );

?>

 

 

Its referring to

mail( "[email protected]", "Quote Form for Organization Group", $combined_message); 

according to DW

<?php
  $Organization_name = $_REQUEST['Organization_name'] ;
  $Contact_name = $_REQUEST['Contact_name'] ;
  $Address = $_REQUEST['Address'] ;
  $Phone = $_REQUEST['Phone'] ;
  $Email = $_REQUEST['Email'] ;
  $Approximate_number_of_employees = $_REQUEST['Approximate_number_of_employees'] ;
  $Are_you_currently_insured = $_REQUEST['Are_you_currently_insured'] ;
  $If_yes_with_whom = $_REQUEST['If_yes_with_whom'] ;
  $What_is_the_best_time_of_day_you_can_be_reached = $_REQUEST['What_is_the_best_time_of_day_you_can_be_reached'] ;
  $Message = $_REQUEST['Message'] ;

  $combined_message="Org Name: $Organization_name\r\nContact Name: $Contact_name\r\nAddress: $Address\r\nPhone: $Phone\r\nEmail: $Email\r\nApprox Employees: $Approximate_number_of_employees\r\nCurrently Insured: $Are_you_currently_insured\r\nWith Whom:$If_yes_with_whom\r\nBest Time to Reach: $What_is_the_best_time_of_day_you_can_be_reached\r\nMessage: $Message";
mail( "[email protected]", "Quote Form for Organization & Group",$combined_message);
  header( "Location:thankyou.html" );
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.