View Full Version : My PHP form sends email but email is blank

02-09-2011, 11:09 PM
I saw a few of these threads but couldn't see in those what was wrong with mine.
Admittedly, I'm very green in PHP so I'm hoping it's just a rookie mistake. My PHP does email me with the correct subject but there is absolutely no message in the email body. The form returns me to the correct URL after submission as well. Hoping you can find what's up?

The PHP form

$event = $_POST['event'] ;
$name = $_POST['name'] ;
$phone = $_POST['phone'] ;
$email = $_POST['email'] ;
$How_did_you_hear_about_us = $_POST['How_did_you_hear_about_us'] ;
$Updates[] = $_POST['Updates[]'] ;
$Terms = $_POST['Terms'] ;
$comments = $_POST['comments'] ;
mail( "info@tonedtraining.com", "Registration",
$message, "From: $email" );
header( "Location: http://www.tonedtraining.com/thankyou.html" );

02-09-2011, 11:12 PM
The form code

<form method="post" name="registration_form" action="registration.php"><!--
<input name="event" size="30" type="hidden" value="This Event Name" />
--><label>Event: <select name="Event"> <option selected
value=yogajan>Yoga</option></select></label><label class="highlight">Name: <input size="30"
name=name> </label><label>Phone: <input size="30" name="phone"> </label><label
class=highlight>Email: <input size="30" name="email"> </label><label>How did you
hear about us?<input size="30" name="How_did_you_hear_about_us"> </label>
<div class="radio_checkbox highlight padded"><input value="Yes" type="checkbox"
name=Updates[]> Would you like to receive e-mail updates? </div><!--<div class="radio_checkbox highlight padded">
Radio Buttons:<br />

<label>yes <input name="radio_buttons" value="yes" type="radio" /></label>

<label>no <input name="radio_buttons" value="no" type="radio" /></label>

<div class="radio_checkbox padded">
Check Boxes:<br /> --><!-- If using checkboxes be sure to include square brackets (ex. name="meal_selections[]") at the end of the name attribute --><!--<label>yes <input name="checkboxes[]" value="yes" type="checkbox" /></label>

<label>no <input name="checkboxes[]" value="no" type="checkbox" /></label>

<label class="highlight">-->
<div class="radio_checkbox padded"><!-- If using checkboxes be sure to include square brackets (ex. name="meal_selections[]") at the end of the name attribute --><input
value=Yes type=checkbox name=Terms> I have read and agree to all <a
href="terms.html (http://members.shaw.ca/girltalkevents/terms.html)" target=blank>Terms and
Conditions</a> (required for registration)</div><label
class=higlight>Questions/Comments: <textarea rows="4" cols="26" name="comments"></textarea> </label>
<div class="submit"><input value="submit" type="submit" name="submit_button">

02-10-2011, 12:23 AM
you have to define $message, that is what you are attempting to send

etc and include the vars you have defined

02-10-2011, 06:57 AM
That did bring content into the email but it came in one long line with no spaces and no titles. How can i add spaces, lines and titles to the email?

02-10-2011, 07:20 AM
.&nbsp;. ==space ."<br>". gives a line break

02-10-2011, 08:26 PM
Awesome, just like HTML.
and one more, really dumb rookie question... (sorry edbr, you're a Godsend!)
How do I get the form to email with field names, like how it will say Name: and then what the customer entered as their name? Right now instead of that, it just says their name. I may lose track of which line is which field and want it to specify, if that makes sense.