I've tried to modify a form I've used successfully, but I'm receiving a blank e-mail message using my modification. What I need this to do is e-mail the results of a customer survey.
All the fields need to be required except the q12 field. The first 11 fields (q1 - q11) are radio buttons with the same 4 choices. The q12 field is a text area. The final field is a textbox for the e-mail address.
I'm not sure what I've done wrong. I've been starting at this code and I just don't see what I've missed. I've read every thread I could find in this forum that dealt with Radio Buttons and didn't find an answer. Could someone help me? I'm posting my script code, but I will post my html code if that is necessary also. Please let me know. I didn't want to post too much code and make everyone mad. I know how frustrating dealing with newbies can be.
I have another question that is mildly related to this as well. I didn't write the form and it used REQUEST instead of POST in all the places where my code now has post. What is the difference between those two things?
One more thing. The version of PHP the server uses is 4.3.3.
<?php
ini_set("SMTP","mail.domain.com");
ini_set("sendmail_from","customerservice@domain.com");
$q1 = $_POST['q1'] ;
$q2 = $_POST['q2'] ;
$q3 = $_POST['q3'] ;
$q4 = $_POST['q4'] ;
$q5 = $_POST['q5'] ;
$q6 = $_POST['q6'] ;
$q7 = $_POST['q7'] ;
$q8 = $_POST['q8'] ;
$q9 = $_POST['q9'] ;
$q10 = $_POST['q10'] ;
$q11 = $_POST['q11'] ;
$q12 = $_POST['q12'] ;
$email = $_POST['email'] ;
if (!isset($_POST['email'])) {
header( "Location: http://www.domain.com/survey.html" );
}
elseif (empty($q1) ||
empty($q2) ||
empty($q3) ||
empty($q4) ||
empty($q5) ||
empty($q6) ||
empty($q7) ||
empty($q8) ||
empty($q9) ||
empty($q10) ||
empty($q11) ||
empty($email))
{
header( "Location: http://www.domain.com/oops.html" );
}
else {
mail( "customerservice@domain.com",
"Customer Survey",
"\rQuestion 1: $q1\n" .
"\rQuestion 2: $q2\n" .
"\rQuestion 3: $q3\n" .
"\rQuestion 4: $q4\n" .
"\rQuestion 5: $q5\n" .
"\rQuestion 6: $q6\n" .
"\rQuestion 7: $q7\n" .
"\rQuestion 8: $q8\n" .
"\rQuestion 9: $q9\n" .
"\rQuestion 10: $q10\n" .
"\rQuestion 11: $q11\n" .
"\rQuestion 12: $q12\n" ,
"From: " . $email . "\r\n" );
header( "Location: http://www.domain.com/thanks.html" );
}
?>
Here's a piece of the form. I didn't want to put all of it because it's so much code. It's the first two questions and the opening form tag only.
<form name="survey" method="post" action="survey.php">
<table width="100%" border="0" cellspacing="5" cellpadding="2">
<tr valign="top">
<td width="4%" align="right" valign="top"><font size="2" face="Arial, Helvetica, sans-serif">1.</font></td>
<td width="52%" valign="top"><font size="2" face="Arial, Helvetica, sans-serif">How
would you rate the navigation of the site?<strong><font color="#FF0000">*</font></strong></font></td>
<td width="44%"><p> <font size="2" face="Arial, Helvetica, sans-serif">
<label><input type="radio" name="q1" value="poor">Poor</label>
<label><input type="radio" name="q1" value="fair">Fair</label>
<label><input type="radio" name="q1" value="good">Good</label>
<label><input type="radio" name="q1" value="excellent">Excellent</label>
</font></p></td>
</tr>
<tr>
<td align="right" valign="top"><font size="2" face="Arial, Helvetica, sans-serif">2.</font></td>
<td valign="top" nowrap><font size="2" face="Arial, Helvetica, sans-serif">How
would you rate the organization and layout of the site?<strong><font color="#FF0000">*</font></strong></font></td>
<td width="44%" valign="top"><p> <font size="2" face="Arial, Helvetica, sans-serif">
<label><input type="radio" name="q2" value="poor">Poor</label>
<label><input type="radio" name="q2" value="fair">Fair</label>
<label><input type="radio" name="q2" value="good">Good</label>
<label><input type="radio" name="q2" value="excellent">Excellent</label>
</font></p></td>