PHP Email script problem

Hello, I am having a problem with my php email script and im at the end of my nerves trying to figure it out. If anyone could help me I would be forever grateful. THANK YOU SO MUCH IN ADVANCE!!

Basically Im making an online guestlist for a wordpress page. I have a contact form that im trying to collect the variables from to send to an email address. The problem Im having is that I cant get the radio box information to send. All the other fields send fine but the event field returns blanks and I cant figure out why.

I have

Here is my code:

// Contact Form
function r_contact_form($atts, $content = null) {
	
	include (TEMPLATEPATH . '/lib/includes/get-options.php');
	$path = get_stylesheet_directory_uri();
	
	$output .= "[raw]<div id=\\"rf\\">";
	$output .= "<input type=\\"hidden\\" value=\\"" . $path . "/lib/includes/contact-form.php\\" id=\\"cp\\"/>";
	$output .= "<p class=\\"rf\\">";
	$output .= "<label>* $r_contact_label_name</label>";
	$output .= "<input type=\\"text\\" value=\\"\\" name=\\"name\\" class=\\"val req\\"/>";
	$output .= "<span></span>";
	$output .= "</p>";
	$output .= "<p class=\\"rf\\">";
	$output .= "<label>* $r_contact_label_email</label>";
	$output .= "<input type=\\"text\\" value=\\"\\" name=\\"email\\" class=\\"val req email\\"/>";
	$output .= "<span></span>";
	$output .= "</p>";
	$output .= "<p class=\\"rf\\">";
	$output .= "<label>$r_contact_label_guests</label>";
	$output .= "<input type=\\"text\\" value=\\"\\" name=\\"guests\\" class=\\"val\\"/>";
	$output .= "<span></span>";
	$output .= "</p>";
	$output .= "<p class=\\"rf\\">";
	$output .= "<label>* $r_contact_label_eventheader</label>";
	$output .= "<ul class=\\"eventclass\\">";
	$output .= "<li<input type=\\"radio\\" value=\\"$r_contact_label_event1\\" name=\\"elist\\" class=\\"val\\"/> $r_contact_label_event1<br></li>";
	$output .= "<li<input type=\\"radio\\" value=\\"$r_contact_label_event2\\" name=\\"elist\\" class=\\"val\\"/> $r_contact_label_event2<br></li>";
	$output .= "<li<input type=\\"radio\\" value=\\"$r_contact_label_event3\\" name=\\"elist\\" class=\\"val\\"/> $r_contact_label_event3<br></li>";
	$output .= "</ul>";
	$output .= "<span></span>";
	$output .= "</p>";
	$output .= "<p class=\\"rf-submit\\">";
	$output .= "<input type=\\"submit\\" value=\\"$r_contact_submit\\" class=\\"submit\\" id=\\"send\\"/>";
	$output .= "<span></span>";
	$output .= "</p>";
	$output .= "</div>[/raw]";
	
   	return $output;
}
add_shortcode('contact_form', 'r_contact_form');

Then Im using this for the mail form:

//VAR
$contact_name = $_POST['name'];
$contact_email = $_POST['email'];
$contact_guests = $_POST['guests'];
$contact_event = $_POST['elist'];

$mailto = $r_email_address;
$subject = $r_subject;
$message = $r_message_text;
$answer = $r_answer;

if ($contact_question != $answer) {
	echo 'bad_answer';
} else {

	$message = str_replace("[NAME]",$contact_name,$message); 
	$message = str_replace("[EMAIL]",$contact_email,$message);
	$message = str_replace("[GUESTS]",$contact_guests,$message); 
	$message = str_replace("[EVENT]",$contact_event,$message);

	//MESSAGE
	$body = "
	<html>
		<head>
			<title>Contact</title>
		</head>
		<body>
			$message
		</body>
	</html>
	";
	
	//E-MAIL FROM
	$mailFrom = "MIME-Version: 1.0\\r\
";
	$mailFrom .= "Content-type: text/html; charset=utf-8\\r\
";
	$mailFrom .= "From: $contact_name <$contact_email>\\r\
";
	
	//SEND MAIL
	
	if(mail($mailto, $subject, $body, $mailFrom)) {
		echo 'success'; 
	} else {
		echo 'error';
	}
}
?>

I know theres some extra wordpress **** in there but thats what im workin with. Please let me know if you can point me in the right direction. Thanks again!!

Im still totally stumped on this…can anyone shed a ray of light on this for me? Thanks again

I’m not sure if it’ll solve your problem, but in the output the close >'s for the li’s are missing:


$output .= "<li[COLOR="Red"]>[/COLOR]<input type=\\"radio\\" value=\\"$r_contact_label_event1\\" name=\\"elist\\" class=\\"val\\"/> $r_contact_label_event1<br></li>";
$output .= "<li[COLOR="Red"]>[/COLOR]<input type=\\"radio\\" value=\\"$r_contact_label_event2\\" name=\\"elist\\" class=\\"val\\"/> $r_contact_label_event2<br></li>";
$output .= "<li[COLOR="Red"]>[/COLOR]<input type=\\"radio\\" value=\\"$r_contact_label_event3\\" name=\\"elist\\" class=\\"val\\"/> $r_contact_label_event3<br></li>";

That might be throwing things off. Otherwise the script looks OK to me at first glance.

Looking at code such as yours always makes me want to cry. Don’t take it the wrong way please, I’ll try to show you what I mean - at a first glance, as it was mentioned - script does look ok. So the next candidate is validating whether your HTML is actually ok. By looking at the script, there’s so many escaped quotes and such so one can’t really determine whether HTML is ok or not by looking at the php code.
Wouldn’t it be better if your code looked like this:

function r_contact_form($atts, $content = null) {
   
    include (TEMPLATEPATH . '/lib/includes/get-options.php');
    $path = get_stylesheet_directory_uri();
   
    $output = '
[raw]<div id="rf">
<input type="hidden" value="' . $path . '/lib/includes/contact-form.php" id="cp"/>
</div>[/raw]
';

    return $output;
} 

I didn’t paste the whole code but you get the idea - you can easily see if you didn’t quote something and such.

Also, have you tried to see if your radio buttons contain any value after your function returned the result?

Yes, They are pulling the dynamic content from my cms. I assume they are fine since I can view the source of the guestlist page and the values are all there in the buttons. They just arent pulling thru my script.

Here is the page in question. http://sip-kc.com/wordpress/guestlist

I ran an html validator and its telling me this:

#  Error  Line 90, Column 538: document type does not allow element "ul" here; missing one of "object", "ins", "del", "map", "button" start-tag

…* Event:</label><ul class="eventclass"><li><input type="radio" value="Voodoo91…

&#9993;

The mentioned element is not allowed to appear in the context in which you've placed it; the other mentioned elements are the only ones that are both allowed there and can contain the element mentioned. This might mean that you need a containing element, or possibly that you've forgotten to close a previous element.

One possible cause for this message is that you have attempted to put a block-level element (such as "<p>" or "<table>") inside an inline element (such as "<a>", "<span>", or "<font>").

Not sure what that means. I checked my syntax and everything looks ok

Since all what happens here is that PHP does something and spits out HTML.
You can then view that html (view > source in many browsers), navigate to the bit where the radio buttons are and check what it says in value attribute.
If there’s nothing there - you know the reason to your problem.

Have you made sure that $r_contact_label_event1, $r_contact_label_event2 and $r_contact_label_event3 all have values?

Ahhh I see what ur sayin, I fixed that but it doesnt change the result. The script still isnt grabbing the ‘elist’ info from the radio buttons. I wonder why…

Thanks for the help, I truely appreciate it. Im not quite following you on the escaping quotes part…do u mean I should cut and past the html so I can follow the code easier? I guess I figured it was all php and didnt think about the html inside getting all foobared when i copied it.

I have not checked to see if my buttons have any value after the script. Im not sure how to check to be honest with ya. Thanks for pointing me in the right direction

Thanks for replying but it appears my close </li> tags are all there right? Ill def go back and check this morning with a fresh set of eyes. Thanks again