PHP Contact Form Problem

  • CXLink
  • Expert
  • Expert
  • User avatar
  • Posts: 685
  • Loc: ATL-GA

Post 3+ Months Ago

Below is the code I am using. The validations seem to be working fine (so I didn't post them but I can if needed). Everything seems like it works but when I receive the email it doesn't have any of the variables in it. Any help is appreciated.

Thanks

HTML
Code: [ Select ]
<form action="emailcon.php" name="form1" id="form1" onSubmit="return validateForm()">
<table width="480" border="0" align="center" cellpadding="5" cellspacing="5">
 <tr class="style1">
  <td colspan="2" valign="top" class="fmtitle"><div align="right">Name*</div></td>
  <td width="240" align="left"><input name="name" id="name" type="text" class="fminput" size="30"/></td>
 </tr>
 <tr class="style1">
  <td colspan="2" valign="top" class="fmtitle"><div align="right">Email Address*</div></td>
  <td><input name="email" id="email" type="text" class="fminput" size="30"/></td>
 </tr>
 <tr class="style1">
  <td colspan="2" valign="top" class="fmtitle"><div align="right">Confirm Email*</div></td>
  <td><input name="emailc" id="emailc" type="text" class="fminput" size="30"/></td>
 </tr>
 <tr class="style1">
  <td colspan="2" valign="top" class="fmtitle"><div align="right">Phone</div></td>
  <td><input name="phone" id="phone" type="text" class="fminput" size="30"/></td>
 </tr>
 <tr class="style1">
  <td colspan="2" valign="top" class="fmtitle"><div align="right">Company</div></td>
  <td><input name="company" id="company" type="text" class="fminput" size="30"/></td>
 </tr>
 <tr class="style1">
  <td colspan="2" valign="top" class="fmtitle"><div align="right">Subject*</div></td>
  <td>
   <select name="subject" id="subject">
    <option selected value="clear">Select Subject</option>
    <option value="RequestDetails">Request Details</option>
    <option value="RequestDemo">Request Demo</option>
    <option value="reqinf">Request Information</option>
    <option value="other">Other</option>
   </select>
  </td>
 </tr>
 <tr class="style1">
  <td colspan="2" valign="top" class="fmtitle"><div align="right">Message</div></td>
  <td align="left"><textarea name="message" id="message" class="fminput" cols="30" rows="6"></textarea></td>
 </tr>
 <tr class="style1">
  <td width="29">&nbsp;</td>
  <td width="173">&nbsp;</td>
  <td align="right"><input type="submit" name="Submit" value="Submit"/></td>
 </tr>
</table>
</form>
  1. <form action="emailcon.php" name="form1" id="form1" onSubmit="return validateForm()">
  2. <table width="480" border="0" align="center" cellpadding="5" cellspacing="5">
  3.  <tr class="style1">
  4.   <td colspan="2" valign="top" class="fmtitle"><div align="right">Name*</div></td>
  5.   <td width="240" align="left"><input name="name" id="name" type="text" class="fminput" size="30"/></td>
  6.  </tr>
  7.  <tr class="style1">
  8.   <td colspan="2" valign="top" class="fmtitle"><div align="right">Email Address*</div></td>
  9.   <td><input name="email" id="email" type="text" class="fminput" size="30"/></td>
  10.  </tr>
  11.  <tr class="style1">
  12.   <td colspan="2" valign="top" class="fmtitle"><div align="right">Confirm Email*</div></td>
  13.   <td><input name="emailc" id="emailc" type="text" class="fminput" size="30"/></td>
  14.  </tr>
  15.  <tr class="style1">
  16.   <td colspan="2" valign="top" class="fmtitle"><div align="right">Phone</div></td>
  17.   <td><input name="phone" id="phone" type="text" class="fminput" size="30"/></td>
  18.  </tr>
  19.  <tr class="style1">
  20.   <td colspan="2" valign="top" class="fmtitle"><div align="right">Company</div></td>
  21.   <td><input name="company" id="company" type="text" class="fminput" size="30"/></td>
  22.  </tr>
  23.  <tr class="style1">
  24.   <td colspan="2" valign="top" class="fmtitle"><div align="right">Subject*</div></td>
  25.   <td>
  26.    <select name="subject" id="subject">
  27.     <option selected value="clear">Select Subject</option>
  28.     <option value="RequestDetails">Request Details</option>
  29.     <option value="RequestDemo">Request Demo</option>
  30.     <option value="reqinf">Request Information</option>
  31.     <option value="other">Other</option>
  32.    </select>
  33.   </td>
  34.  </tr>
  35.  <tr class="style1">
  36.   <td colspan="2" valign="top" class="fmtitle"><div align="right">Message</div></td>
  37.   <td align="left"><textarea name="message" id="message" class="fminput" cols="30" rows="6"></textarea></td>
  38.  </tr>
  39.  <tr class="style1">
  40.   <td width="29">&nbsp;</td>
  41.   <td width="173">&nbsp;</td>
  42.   <td align="right"><input type="submit" name="Submit" value="Submit"/></td>
  43.  </tr>
  44. </table>
  45. </form>


PHP
Code: [ Select ]
<?php

import_request_variables("P","par_");

$sendTo = "recipient@email.com";
$subject = "ContactUS: " . $par_subject;

$headers = "From: " . $par_name;
$headers .= "<" . $par_email . ">\r\n";
$headers .= "Reply-To: " . $par_email . "\r\n";
$headers .= "Return-Path: " . $par_email;

$message .= "Name: " . $par_name . "\r\n";
$message .= "Company: " . $par_company . "\r\n";
$message .= "Phone: " . $par_phone . "\r\n";
$message .= $par_message;

mail($sendTo, $subject, $message, $headers);

$url = "http://www.website.com/contactc.html"; // target of the redirect
$delay = "0"; // 3 second delay

echo '<meta http-equiv="refresh" content="'.$delay.';url='.$url.'">';
?>
  1. <?php
  2. import_request_variables("P","par_");
  3. $sendTo = "recipient@email.com";
  4. $subject = "ContactUS: " . $par_subject;
  5. $headers = "From: " . $par_name;
  6. $headers .= "<" . $par_email . ">\r\n";
  7. $headers .= "Reply-To: " . $par_email . "\r\n";
  8. $headers .= "Return-Path: " . $par_email;
  9. $message .= "Name: " . $par_name . "\r\n";
  10. $message .= "Company: " . $par_company . "\r\n";
  11. $message .= "Phone: " . $par_phone . "\r\n";
  12. $message .= $par_message;
  13. mail($sendTo, $subject, $message, $headers);
  14. $url = "http://www.website.com/contactc.html"; // target of the redirect
  15. $delay = "0"; // 3 second delay
  16. echo '<meta http-equiv="refresh" content="'.$delay.';url='.$url.'">';
  17. ?>
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9089
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

In your HTML make sure you have method="post" as I believe by default it is a GET request when you don't specify a method. When you say:

PHP Code: [ Select ]
import_request_variables("P","par_");


You are saying only look for post variables. So this:

HTML Code: [ Select ]
<form action="emailcon.php" name="form1" id="form1" onSubmit="return validateForm()">


should probably be:

HTML Code: [ Select ]
<form action="emailcon.php" name="form1" id="form1" onSubmit="return validateForm()" method="post">


Let me know if that fixes it.
  • CXLink
  • Expert
  • Expert
  • User avatar
  • Posts: 685
  • Loc: ATL-GA

Post 3+ Months Ago

Works wonders. Thanks Brian.

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 96 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.