PDA

View Full Version : web site form sending blank email results...


kingofpuck12
05-16-2012, 10:17 PM
This is my first time using Dreamweaver since an intro .html class in college so I'm still a beginner at all of this.

I've created a simple site with a form where the results are sent to my e-mail address. Everything is working perfectly except the results are blank. When I test the form, I get an e-mail from my site that simply says "Results from form:" and the rest is blank. I don't see any of my form questions (ie name, age, location, etc...). It's just simply blank. My server does allow PHP.

I think it has to do with my code for my site.

Here is the form code

<form action="www.MYWEBSITE.com/sendresults.php" method="post" enctype="multipart/form-data" name="form1">
<p>&nbsp;</p>
<table width="720" border="0" align="center">
<tr>
<td width="62">&nbsp;</td>
<td width="284"><div align="right">First Name</div></td>
<td width="284"><div align="left">
<input name="First Name" type="text" id="First Name" size="25">
</div></td>
<td width="62">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right">Last Name</div></td>
<td><div align="left">
<input name="Last Name" type="text" id="Last Name" size="25">
</div></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right">Age</div></td>
<td><div align="left">
<select name="Age" size="1" id="Age">
<option selected>-</option>
<option>40</option>
<option>41</option>
<option>42</option>
<option>43</option>
<option>44</option>
<option>45</option>
<option>46</option>
<option>47</option>
<option>48</option>
<option>49</option>
<option>50</option>
<option>Other</option>
</select>
</div></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right">Email Address</div></td>
<td><div align="left">
<input name="Email Address" type="text" id="Email Address" size="25">
</div></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right">Phone Number</div></td>
<td><div align="left">
<input name="Phone Number" type="text" id="Phone Number" size="25" maxlength="10">
</div></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right">Address</div></td>
<td><div align="left">
<input name="Address" type="text" id="Address" size="25">
</div></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right"></div></td>
<td><div align="left">
<input name="Address line 2" type="text" id="Address line 2" size="25">
</div></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right">Town</div></td>
<td><div align="left">
<input name="Town" type="text" id="Town" size="25">
</div></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right">State</div></td>
<td><div align="left">
<select name="State" id="State">
<option selected>-</option>
<option>Massachusetts</option>
<option>Maine</option>
<option>New Hampshire</option>
</select>
</div></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right">Zip Code</div></td>
<td><div align="left">
<input name="Zip Code" type="text" id="Zip Code" size="7" maxlength="5">
</div></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right">Residence Type</div></td>
<td><div align="left">
<select name="Residence Type" id="Residence Type">
<option selected>-</option>
<option>Apartment</option>
<option>Condo</option>
<option>House</option>
<option>Summer Rental</option>
</select>
</div></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right"></div></td>
<td><div align="left"></div></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right"></div></td>
<td><div align="left"></div></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right">Marital Status</div></td>
<td><div align="left">
<select name="Marital Status" id="Marital Status">
<option selected>-</option>
<option>Single</option>
<option>Dating</option>
<option>Married</option>
<option>Divorced</option>
<option>Seperated</option>
<option>Other</option>
</select>
</div></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right">Occupation</div></td>
<td><div align="left">
<input name="Occupation" type="text" id="Occupation" size="25">
</div></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right">Yearly Salary </div></td>
<td><div align="left">
<select name="Yearly Salary" id="Yearly Salary">
<option selected>-</option>
<option>under $35,000</option>
<option>$35,000 - $50,000</option>
<option>$50.000 - $75,000</option>
<option>$75,000 - $100,000</option>
<option>over $100,000</option>
</select>
</div></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right"></div></td>
<td><div align="left"></div></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right"></div></td>
<td><div align="left"></div></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right">What are your favorite bars and locations to pick up women?</div></td>
<td><div align="left">
<textarea name="Favorite Bars/Locations" cols="35" rows="8" id="Favorite Bars/Locations"></textarea>
</div></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right">What is you age preference in women?</div></td>
<td><div align="left">
<select name="Women age preference" id="Women age preference">
<option selected>-</option>
<option>under 23</option>
<option>23-26</option>
<option>26-29</option>
<option>over 29</option>
<option>No Preference</option>
</select>
</div></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right">What do you like in a woman?</div></td>
<td><div align="left">
<textarea name="What do you like in a woman?" cols="35" rows="8" id="What do you like in a woman?"></textarea>
</div></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right">On average, how many women will you sleep with in one month?</div></td>
<td><div align="left">
<select name="Average women per month?" id="Average women per month?">
<option selected>-</option>
<option>only 1</option>
<option>1-3</option>
<option>3-5</option>
<option>over 5</option>
</select>
</div></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right"></div></td>
<td><div align="left"></div></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right"></div></td>
<td><div align="left"></div></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right">On average, how many drinks will you consume on a night out?</div></td>
<td><div align="left">
<select name="How many drinks per night?" id="How many drinks per night?">
<option selected>-</option>
<option>less than 3</option>
<option>3-5</option>
<option>5-9</option>
<option>9-12</option>
<option>over 12</option>
</select>
</div></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right">Why do women like you?</div></td>
<td><div align="left">
<textarea name="Why do women like you?" cols="35" rows="8" id="Why do women like you?"></textarea>
</div></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right">Briefly decsribe a typical night out</div></td>
<td><div align="left">
<textarea name="Briefly describe a typical night out." cols="35" rows="8" id="Briefly describe a typical night out."></textarea>
</div></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right"></div></td>
<td><div align="left"></div></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right">Are you on Facebook?</div></td>
<td><div align="left">
<select name="Are you on Facebook?" id="Are you on Facebook?">
<option selected>-</option>
<option>Yes</option>
<option>No</option>
</select>
</div></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><p align="right">Are you on Twitter?<br>
</p></td>
<td><div align="left">
<select name="Are you on Twitter?" id="Are you on Twitter?">
<option selected>-</option>
<option>Yes</option>
<option>No</option>
</select>
</div></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right">Do you use online dating sites?</div></td>
<td><div align="left">
<select name="Do you use online dating sites?" id="Do you use online dating sites?">
<option selected>-</option>
<option>Yes</option>
<option>No</option>
</select>
</div></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right"></div></td>
<td><div align="left"></div></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right">Have you ever acted or been on camera?</div></td>
<td><div align="left">
<select name="Have you ever acted or been on camera?" id="Have you ever acted or been on camera?">
<option selected>-</option>
<option>Yes</option>
<option>No</option>
</select>
</div></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right"></div></td>
<td><div align="left"></div></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right">Please upload a recent, clear photo of yourself</div></td>
<td><div align="left">
<input type="file" name="Recent Photo" id="Recent Photo">
</div></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right"></div></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td colspan="2"><div align="center"></div>
<div align="center"><a href="http://www.MYWEBSITE.com/sendresults.php">Submit</a></div></td>
<td>&nbsp;</td>
</tr>
</table>
</form>



And here is the code for my PHP. I took this code from a forum on this website.

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

// Subject of email sent to you.
$subject = 'Results from Form';

// Your email address. This is where the form information will be sent.
$emailadd = 'contact@MYWEBSITE.com';

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

// 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 = '0';

// --------------------------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.'">';
?>


If anyone knows what the issue is I would appreciate it!

Alex

kingofpuck12
05-16-2012, 10:29 PM
I have gone through post here that cover this issue but I still cannot figure out the problem. Didn't want to re-post this question again but I have yet to figure it out for a few days now by going over old posts like this.

davidj
05-16-2012, 10:51 PM
what you need to do is find where its failing by process of elimination

where you see this in your script...


mail($emailadd, $subject, $text, 'From: '.$emailadd.'');


try this above the mail function...



echo $emailadd . " - ". $subject . " - ". $text . " - ". $emailadd
exit;



and submit it as normal to see if you get results displayed to the screen.

kingofpuck12
05-17-2012, 02:59 AM
what you need to do is find where its failing by process of elimination

where you see this in your script...


mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
try this above the mail function...



echo $emailadd . " - ". $subject . " - ". $text . " - ". $emailadd
exit;

and submit it as normal to see if you get results displayed to the screen.


When I add this code it, Dreamweaver says I have a syntax error. Sorry if I sound like a beginner, I'm just very new to this. I appreciate all the help!

davidj
05-17-2012, 05:26 AM
That's because dreamweaverclub was right!

Try this...

echo $emailadd."-".$subject."-".$text."-".$emailadd;
exit;

edbr
05-17-2012, 05:50 AM
a semi colonoscopy

davidj
05-17-2012, 06:43 PM
Aye nothing like messing up your colon!