Sorry to bug you guys with this, I know you probably get way too many questions about this sort of thing. I'm new to PHP (this is my 4th day). I'm trying to build an online poll using radio buttons. I've used some help from this forum but I still can't get it to work. Could someone look through my code and tell me whats wrong, or if I'm even in the right ballpark with this? Thanks.
<body bgcolor="#ffffff">
<?php
$radio_newjersey_checked = " ";
$radio_pittsburgh_checked = " ";
$radio_colorado_checked = " ";
$radio_stlouis_checked = " ";
$submit = " ";
if ($submit) {
$db = mysql_connect("localhost", "login", "passwd");
mysql_select_db("my_db",$db);
// process form
if ($radio_button == "newjersey") {
$radio_newjersey_checked = "CHECKED";
$sql = "UPDATE poll SET newjersey = newjersey +1";
$result = mysql_query($sql);
echo "Thank you! Information entered.\n";
}
elseif ($radio_button == "pittsburgh") {
$radio_pittsburgh_checked = "CHECKED";
$sql = "UPDATE poll SET pittsburgh = pittsburgh +1";
$result = mysql_query($sql);
echo "Thank you! Information entered.\n";
}
elseif ($radio_button == "colorado") {
$radio_colorado_checked = "CHECKED";
$sql = "UPDATE poll SET colorado = colorado +1";
$result = mysql_query($sql);
echo "Thank you! Information entered.\n";
}
elseif ($radio_button == "stlouis") {
$radio_stlouis_checked = "CHECKED";
$sql = "UPDATE poll SET stlouis = stlouis +1";
$result = mysql_query($sql);
echo "Thank you! Information entered.\n";
} else {
// display form
?>
<form method="post" name="poll" id="poll" action="<?php echo $PHP_SELF?>">
<table bgcolor=black>
<tr>
<td bgcolor=black colspan=2>
<font face=verdana color=white size=3>
<p><b>Who do you think will win the Stanley Cup?</b><hr color=red></td>
<tr><td bgcolor=black valign=top><font face=verdana color=white size=3>
<input type="radio" name="radio_button" value="<?php \'newjersey\' $radio_newjersey_checked ?>">New Jersey<br>
<input type="radio" name="radio_button" value="<?php \'pittsburgh\' $radio_pittsburgh_checked ?>">Pittsburgh<br></td>
<td bgcolor=black valign=top><font face=verdana color=white size=3>
<input type="radio" name="radio_button" value="<?php \'colorado\' $radio_colorado_checked ?>">Colorado<br>
<input type="radio" name="radio_button" value="<?php \'stlouis\' $radio_stlouis_checked ?>">St. Louis</p></td></tr>
<tr><td bgcolor=black><font face=verdana color=white size=3><a href="">results</a></td><td bgcolor=black><input type = "submit" value ="<?php \'submit\' $submit ?>"></td></tr>
<?php
} // end if
?>
</body>