Hey,
This problem should be easy to fix, I just wanted to see if anyone had a quick solution to my problem.
Here's the problem:
When a user rates, the script prints a mesage stating that the user has rated. When a user does not select a rating and still clicks on the submit button, he SHOULD get a message stating that he has not rated. This message is not displaying and I'm not sure why.
Here is the code I have so far:
Code:
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
///////////////results.txt updater///////////////////////
$rate = $_POST["rate"];
if ($rate) {
if ($rate>0) {
$File = "results.txt";
$Handle = fopen($File, 'a');
$Data = "$rate\n";
fwrite($Handle, $Data);
print "<small>Thanks for the rating!</small>";
fclose($Handle);
}
elseif ($rate==0) { //
print "<small>Please select a rating.</small>"; //this is the problem area
} //
}
//////////////////////Rating form//////////////////////////////////////////
echo "<form name=\"rating_form\" method=\"post\">";
echo "<select name=\"rate\">";
echo "<option value=\"0\">--rate--</option>";
echo "<option value=\"100\">5</option>";
echo "<option value=\"80\">4</option>";
echo "<option value=\"60\">3</option>";
echo "<option value=\"40\">2</option>";
echo "<option value=\"20\">1</option>";
echo "</select>";
echo "<input name=\"submit\" type=\"submit\" value=\"Submit\">";
echo "</form>";
echo "<table width=\"200\" border=\"1\" bordercolor=\"#666666\" cellpadding=\"0\" cellspacing=\"0\">";
echo "<tr>";
echo " <td style=\"$is_green_fix\" width=\"$result%\" height=\"15\"></td>";
echo "<td width=\"$width_white\" style=\"$no_green_fix\"></td>";
echo "</tr>";
echo "</table>";
?>
</body>
</html>
Thanks for the help,
Moatist
|