PDA

View Full Version : Email form is sent but empty!


agoch01
01-18-2011, 07:05 PM
Hi there... I'm new to web design and I am trying to get a form to work! :(

I used this tutorial: http://www.dreamweaverclub.com/dreamweaver-php-form.php

It sends an email to the user, but the email itself is totally blank.

This is the really simple website I made: http://www.gregandmorgan.com/

It seems to send and everything but I'm not sure I did the PHP correctly.

In the tutorial it just says to copy/past the PHP code and save it as sendfile.php. I made a new PHP document in dreamweaver, but didn't change whether it was an XHTML, HTML, etc... would this matter? And I removed all the text from the new document and pasted in the PHP code. Is this right?

Again, it sends to the specified email address, redirects to the website, etc... but there is nothing in the email :(

HELP!

Thanks a bunch!

agoch01
01-18-2011, 07:11 PM
This is the HTML for my form:


<form id="RSVP form" name="RSVP form" method="post" action="/sendresults.php">
<table width="70%" class="formtable" border="0" bgcolor="#ffffff"align="center" cellpadding="2" cellspacing="1" summary="Table used for form layout">
<tr>
<th colspan="2" scope="col">&nbsp;</th>
</tr>
<tr>
<td width="30%" class="forminfo"><input name="required" type="hidden" id="required" value="first_name, last_name, email, attending" />
*First Name:</td>
<td width="70%" align="left"><label for="first_name"></label>
<input name="first_name" type="text" id="first_name" size="40" maxlength="100"/>
</td>
</tr>
<tr>
<td class="forminfo">*Last Name:</td>
<td align="left"><label for="last_name"></label>
<input name="last_name" type="text" id="last_name" size="40" maxlength="100" /></td>
</tr>
<tr>
<td class="forminfo">*Email:</td>
<td align="left"><label for="email"></label>
<input name="email" type="text" id="email" size="40" maxlength="100" /></td>
</tr>

<tr>
<td class="forminfo">*Can you make it?</td>
<td><p class="forminfo">
<label>
<input type="radio" name="attendants" value="positive" id="attendants_0" />
We'll be there!</label>
<br />
<label>
<input type="radio" name="attendants" value="negative" id="attendants_1" />
Sorry, </label>
we can't make it :(<br />
</td>
</tr>
<tr>
<td class="forminfo">Total Count:</td>
<td align="left"><label for="attending"></label>
<input name="attending" type="text" id="attending" size="10" maxlength="3" /></td>
</tr>
<tr>
<td class="forminfo">We'd love to hear your thoughts!</td>
<td align="left"><textarea name="comments" id="comments" cols="50" rows="6"></textarea></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" name="submit" id="submit" value="{Submit}" /> &nbsp;
<input type="reset" name="reset" id="reset" value="{Reset}" /></td>
</tr>
<tr>
<td colspan="2" class="required">*required field</td>
</tr>
</table>
</form>

agoch01
01-18-2011, 07:11 PM
This is my entire PHP:


<?php
//--------------------------Set these paramaters--------------------------

// Subject of email sent to you.
$subject = 'RSVP form';

// Your email address. This is where the form information will be sent.
$emailadd = 'morgan@quo.cc';

// Where to redirect after form is processed.
$url = 'http://www.gregandmorgan.com';

// Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty.
$req = '1';

// --------------------------Do not edit below this line--------------------------
$text = "Results from form:\n\n";
$space = ' ';
$line = '
';
foreach ($_POST as $key => $value)
{
if ($req == '1')
{
if ($value == '')
{echo "$key is empty";die;}
}
$j = strlen($key);
if ($j >= 20)
{echo "Name of form element $key cannot be longer than 20 characters";die;}
$j = 20 - $j;
for ($i = 1; $i <= $j; $i++)
{$space .= ' ';}
$value = str_replace('\n', "$line", $value);
$conc = "{$key}:$space{$value}$line";
$text .= $conc;
$space = ' ';
}
mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
?>

diego715
02-09-2011, 04:04 AM
At least do you recieve "the results from form"?

edbr
02-09-2011, 04:42 AM
this part often causes problems i believe, increase the number at least


if ($j >= 20)
{echo "Name of form element $key cannot be longer than 20 characters";die;}
$j = 20 - $j;