Jump to content

Need Help with my php code please!


lauraccb

Recommended Posts

Here is the php code I currently have.  The problem is that when I enter values for each field and the form is submitted, "alternate phone", "best time to call", and "best time for your free estimate" don't show the values I entered when it comes to my email.  Any help is greatly appreciated!!!  Thanks!

 

<?php
define(FORM_TO,'[email protected]');



$name = $_GET['name'];
$email = $_GET['email'];
$phone = $_GET['phone'];
$alternatephone = $_GET['alternatephone'];
$address = $_GET['address'];
$city = $_GET['city'];
$state = $_GET['state'];

$name = $_REQUEST['name'] ;
$email = $_REQUEST['email'] ;
$phone = $_REQUEST['comments'] ;
$alternatephone = $_REQUEST['alternate phone'] ;
$address = $_REQUEST['address'] ;
$city = $_REQUEST['city'] ;
$state = $_REQUEST['state'] ;
$zip = $_REQUEST['zip'] ;
$best_time_to_call = $_REQUEST['best time to call?'] ;
$best_time_for_your_free_estimate = $_REQUEST['best time for your free estimate?'] ;
$comments = $_REQUEST['comments'] ;

$product_name = $_GET['product_name'];

$curdate = date("r");


$to      = FORM_TO;
$subject = $product_name . ' Form Mail';
$headers = 'From: [email protected]'. "\r\n";

$message = "


Name:\t $name
Email:\t $email
Phone:\t $phone
Alternate Phone:\t $alternatephone
Address:\t $address
City:\t $city
State:\t $state
Zip:\t $zip
Best Time to Call?:\t $best_time_to_call
Best Time for your free estimate?:\t $best_time_for_your_free_estimate
Comments:\t $comments

$howhelp



Date/Time Stamp:  $curdate

";



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


#echo "<pre>";
#print_r($_GET);
#echo "</pre>";

header("Location: thankyou.html");
?>

 

(edited by kenrbnsn to add


tags)

Link to comment
https://forums.phpfreaks.com/topic/99190-need-help-with-my-php-code-please/
Share on other sites

Please post the code for your form between


tags.

 

Why are you using both the $_GET and $_REQUEST arrays to obtain the values? If your form uses 'method="GET"' the values will be in the $_GET array. If it uses 'method="post"' then use the $_POST array.

 

Ken

Sorry, here is the html code in the contact page:

 

 

<form METHOD="POST" ACTION="php2.php"> 
<INPUT TYPE=HIDDEN NAME="recipient" VALUE="[email protected]"> 
<INPUT TYPE=HIDDEN NAME="subject" VALUE="Form Submitted Email"> 
<input type=hidden name="redirect" value="http://www.thebathsolution.net/thankyou.html">



<br>

<table  id="contact_form" align="center" cellspacing="5"><br>
<caption><sup><span class="importance"></span></sup> <span class="note"><b><font size="+1">Complete Today and Submit for your FREE Estimate!</font></span><br> 
</caption>
<input type=hidden name="redirect" value="http://www.thebathsolution.net/thankyou.html"> 

<tr><td class="contact_label">Name<sup><span class="importance">*</span></sup> 
<td><input type=text size=40 name="name" value="">
<tr><td class="contact_label">Email<sup><span class="importance">*</span></sup> 
<td><input type=text size=40 name="email" value="">
<tr><td class="contact_label">Phone<sup><span class="importance">*</span></sup> 
<td><input type=text size=40 name="phone" value="">
<tr><td class="contact_label">Alternate Phone 
<td><input type=text size=40 name="alternate phone" value="">
<tr><td class="contact_label">Address 
<td><input type=text size=40 name="address" value="">
<tr><td class="contact_label">City 
<td><input type=text size=40 name="city" value="">
<tr><td class="contact_label">State 
<td><input type=text size=40 name="state" value="">
<tr><td class="contact_label">Zip 
<td><input type=text size=40 name="zip" value="">
<tr><td class="contact_label">Best Time to Call? 
<td><input type=text size=40 name="Best Time to call?" value="">
<tr><td class="contact_label">Best Time for your free estimate? 
<td><input type=text size=40 name="Best Time for your free estimate?" value="">
<tr><td class="contact_label">Comments<sup><span class="importance">*</span></sup> 
<td><textarea name="comments" rows="5" wrap="" cols="30" >
</textarea>
<tr><td> <td align="center"><input type="submit" name="submit" value="Submit"></table></form>
<style>
#contact_form{
	font-family:verdana, helvetica, sans-serif; 
	font-size:10pt;
	height: 75;
}
#contact_form caption {text-align:center; height: 40px;}	

.importance { color:#990000; font-size:14pt; }

.contact_label { text-align:right; }

.error {color:#990000; font-size:12pt;}

#contact_form .note { color:#990000; font-size:10pt;} /* line-height:3ex;}*/

#contact_form .thanks {color: #009900; font-size:12pt; font-weight:bold;}

</style></td>
        </tr>
      </table>
  <Br></td>

 

(edited by kenrbnsn to add


tags)

Names in the <input> tag shouldn't have spaces or special characters in them. Change your form to (in part)

<tr><td class="contact_label">Alternate Phone 
<td><input type=text size=40 name="alternate_phone" value="">
<tr><td class="contact_label">Address 
<td><input type=text size=40 name="address" value="">
<tr><td class="contact_label">City 
<td><input type=text size=40 name="city" value="">
<tr><td class="contact_label">State 
<td><input type=text size=40 name="state" value="">
<tr><td class="contact_label">Zip 
<td><input type=text size=40 name="zip" value="">
<tr><td class="contact_label">Best Time to Call? 
<td><input type=text size=40 name="best_time_call" value="">
<tr><td class="contact_label">Best Time for your free estimate? 
<td><input type=text size=40 name="best_time_free" value="">

 

Then change the php script to:

<?php
$name = $_POST['name'] ;
$email = $_POST['email'] ;
$phone = $_POST['comments'] ;
$alternatephone = $_POST['alternate_phone'] ;
$address = $_POST['address'] ;
$city = $_POST['city'] ;
$state = $_POST['state'] ;
$zip = $_POST['zip'] ;
$best_time_to_call = $_POST['best_time_call?'] ;
$best_time_for_your_free_estimate = $_POST['best_time_free'] ;
?>

 

Get rid of the lines that reference $_GET, since your form doesn't use the GET method. Change any references to $_REQUEST to $_POST.

 

Ken

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.