I Have been trying to get a Php script working for the better part of a week :-/. I've kept it super simple, and I still cannot seem to figure this one out... strangely...
It functions well enough that I receive the email with the following message:
Name:
Phone number:
Email Address :
Street Address:
Managment Contact:
As you can see-- no data makes it through to me though.
This is the HTML form:
<td width="487" height="240" bgcolor="#1D1D1D"><form action="Contact form/processrequest.php" method="post" name="request form" target="_parent" id="request form">
<table width="488" border="0" cellspacing="0" cellpadding="6">
<tr>
<td width="161" height="34" align="right"><label for="name" class="adf">Name </label></td>
<td width="303" align="left" bgcolor="#1D1D1D"><input name="Name" type="text" id="Name" size="50" maxlength="200" /></td>
</tr>
<tr>
<td height="34" align="right" class="adf"><label for="phone">Phone Number </label></td>
<td align="left"><input name="Phone Number " type="text" id="Phone Number " size="50" maxlength="300" /></td>
</tr>
<tr>
<td height="34" align="right" class="adf"><label for="email">Email Address </label></td>
<td align="left"><input name="Email Address" type="text" id="Email Address" size="50" maxlength="300" /></td>
</tr>
<tr>
<td height="34" align="right" class="adf"><label for="street">Street Address </label></td>
<td align="left"><input name="Street Address" type="text" id="Street Address" size="50" maxlength="300" /></td>
</tr>
<tr>
<td height="34" align="right" class="adf"><label for="mgmt">MGMT Contact </label></td>
<td align="left"><input name="Management Contact" type="text" id="Management Contact" size="50" maxlength="300" /></td>
</tr>
<tr>
<td height="36" align="right"> </td>
<td align="left"><input type="submit" name="Send" id="Send" value="Submit" /></td>
and this is the PHP:
<?php
// Get Data
$name= "$name";
$phone= "$phone";
$email= "$email";
$street= "$street";
$mgmt= "$mgmt";
// Send Message
mail( "myemail@my.com", "Contact From Website",
"Name: $name
Phone number: $phone
Email Address : $email
Street Address: $street
Managment Contact: $MGMT
",
"From: Wearable Collections Facebook App Bin Request Form <myemail@my.com>" );
?>
I feel like I am probably missing something very obvious--- so any help would be much appreciated!!!!
The problem is here:
$name= "$name";
To get form data, you should use:
$name = $_POST['name'];
Repeat for each of your form fields, and you will have a working set of data.
It's how you're getting your data.
Try it as follows.
Also, please see the security notes below.
<?php
// Get Data
$name= $_REQUEST["name"]; // Works for both get and post, as opposed to $_GET["name"] or $_POST["name"];
$phone= $_REQUEST["phone"];
$email= $_REQUEST["email"];
$street= $_REQUEST["street"];
$mgmt= $_REQUEST["mgmt"];
// Send Message
mail( "myemail@my.com", "Contact From Website",
"Name: $name
Phone number: $phone
Email Address : $email
Street Address: $street
Managment Contact: $MGMT
",
"From: Wearable Collections Facebook App Bin Request Form <myemail@my.com>" );
?>
More about working with PHP and Forms here:
http://php.net/manual/en/tutorial.forms.php
More about $_REQUEST here:
http://www.php.net/manual/en/reserved.variables.php
IMPORTANT!!!!! Also see these articles on security, which you should learn hand-in-hand with form processing:
http://phpsense.com/2006/php-email-injection-attacks/
http://www.sitepoint.com/php-security-blunders/
http://php.net/manual/fr/function.mysql-real-escape-string.php