I normally use cgi-scripts to create online contact forms. This time I need to use php to create a form. When I submit the sample form online, I receive an e-mail and go to the thank you page. However, the e-mail that I receive doesn't contain any data. Here is my php:
<?php
$date = $_REQUEST['date'] ;
$waterway = $_REQUEST['waterway'] ;
$organization = $_REQUEST['organization'] ;
$contact = $_REQUEST['contact'] ;
$phone = $_REQUEST['phone'] ;
$email = $_REQUEST['email'] ;
$miles = $_REQUEST['miles'] ;
$adults = $_REQUEST['adults'] ;
$children = $_REQUEST['children'] ;
$amount = $_REQUEST['amount'] ;
$type = $_REQUEST['type'] ;
$unusual = $_REQUEST['unusual'] ;
$hours = $_REQUEST['hours'] ;
$comments = $_REQUEST['comments'] ;
mail( "I put my e-mail address here", "Cleanup Data Form",
$message, "From: $email" );
header( "this is the link to the thank you page" );
?>
Here is the html form:
<form action="sendmail.php" method="post">
<table width="500" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="193" height="40" valign="top">Date of cleanup:</td>
<td colspan="2" valign="top">
<label>
<input name="date" type="text" id="date" size="50">
</label>
</td>
</tr>
<tr>
<td height="43" valign="top">Waterway adopted:</td>
<td colspan="2" valign="top">
<label>
<input name="waterway" type="text" id="waterway" size="50">
</label>
</td>
</tr>
<tr>
<td valign="top" height="40">Adopting organization:</td>
<td colspan="2" valign="top">
<label>
<input name="organization" type="text" id="organization" size="50">
</label>
</td>
</tr>
<tr>
<td valign="top" height="40">Name of contact person:</td>
<td colspan="2" valign="top">
<label>
<input name="contact" type="text" id="contact" size="50">
</label>
</td>
</tr>
<tr>
<td valign="top" height="40">Phone number:</td>
<td colspan="2" valign="top">
<label>
<input name="phone" type="text" id="phone" size="50">
</label>
</td>
</tr>
<tr>
<td valign="top" height="40">E-mail address:</td>
<td colspan="2" valign="top">
<label>
<input name="email" type="text" id="email" size="50">
</label>
</td>
</tr>
<tr>
<td valign="top" height="40">Number of miles cleaned:</td>
<td colspan="2" valign="top">
<label>
<input name="miles" type="text" id="miles" size="50">
</label>
</td>
</tr>
<tr>
<td valign="top" height="72">Indicate the number of participants:</td>
<td width="50" valign="top">
</td>
<td width="257" valign="top"><label># Adults
<input name="adults" type="text" id="adults" size="3">
</label>
<label><br>
<br>
Children
<input name="children" type="text" id="children" size="3">
</label></td>
</tr>
<tr>
<td valign="top" height="40">Number of bags or weight collected:</td>
<td colspan="2" valign="top">
<label>
<input name="amount" type="text" id="amount" size="50">
</label>
</td>
</tr>
<tr>
<td valign="top" height="40">Type of trash collected:</td>
<td colspan="2" valign="top">
<label>
<input name="type" type="text" id="type" size="50">
</label>
</td>
</tr>
<tr>
<td valign="top" height="40">Most unusual item found:</td>
<td colspan="2" valign="top">
<label>
<input name="unusual" type="text" id="unusual" size="50">
</label>
</td>
</tr>
<tr>
<td valign="top" height="40">Cleanup Time (in hours):</td>
<td colspan="2" valign="top">
<label>
<input name="hours" type="text" id="hours" size="50">
</label>
</td>
</tr>
<tr>
<td height="85" valign="top">Comments:</td>
<td colspan="2" valign="top"><textarea name="comments" rows="3"></textarea></td>
</tr>
<tr><td colspan="3"><div align="center">
<input type="submit" name="submit" value="submit"/>
</div></td></tr>
</table>
</form>
I'd greatly appreciate any help you can provide.
E-mail Contact Form Not Submitting Data
Moderator: General Moderators
- iankent
- Forum Contributor
- Posts: 333
- Joined: Mon Nov 16, 2009 4:23 pm
- Location: Wales, United Kingdom
Re: E-mail Contact Form Not Submitting Data
In this bit:
you pass a variable $message that hasn't been set.
at the top where you get all of your data from $_REQUEST, you'll need to join them together in a variable called $message to create the text you want to send, e.g.
and so on.
hth
edit: to correct some code
Code: Select all
mail( "I put my e-mail address here", "Cleanup Data Form",
$message, "From: $email" );at the top where you get all of your data from $_REQUEST, you'll need to join them together in a variable called $message to create the text you want to send, e.g.
Code: Select all
$message = 'Hi whatever,\n\n,Request date:$date\nWaterway: $waterway\n"hth
edit: to correct some code