I've searched through the PHP manual and this forum until I'm blue in the face and can't seem to find the answer to my question, so I appologize in advance if this has been asked and answered previously.
I can't seem to figure out how to grab the actual value of a radio button, which is checked and submitted through a form, processed by PHP and added to a MySQL database. In javascript, I would use a for loop to step through the values and figure out which one is checked, add it's value to a variable and use it from there. However, either my brain is fried tonight and I'm not seeing the obvious, or ...... my brain is just plain fried!
Here's the code that does NOT work. It fills the database with nothing in that field. Could someone please give me a clue how to grab the value of this dang radio button?
Code: Select all
<?PHP
// some security stuff goes here but has been removed for display purposes
// assume user is logged in and has appropriate userlevel if they made it this far
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#cfdac5" text="#003300" link="#006600" vlink="#003300">
<?
// check to see if this form reached by clicking submit to add an entry
if ($submit) {
$org1 = $HTTP_POST_VARS["org"];
$clnum1 = intval($HTTP_POST_VARS["clnum"]);
$cldescr1 = $HTTP_POST_VARS["cldescr"];
$aglim1 = $HTTP_POST_VARS["agelim"];
$agereq1 = $HTTP_POST_VARS["agereq"];
$sql = "INSERT INTO classlist (org,clnum,cldescr,agelim,agereq)
VALUES ('$org1','$clnum1','$cldescr1','$agelim1','$agereq1')";
$result = mysql_query($sql) or die("Invalid Query");
echo "<p align="center">$org $clnum $cldescr $agelim $agereq <br>
<b>added to the database</b>.</p>";
echo "<p align="center"><a href="dbadrec.php?action=additnow">Add another</a></p>";
echo "<p align="center"><a href="dbadmin.php?action=addconfirmed">All Done</a></p>";
}
else {
?>
<form name="addform1" method="POST" action="dbadrec.php">
<fieldset>
<legend><font size="-1">Add DB Records</font></legend>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<th align="center"><font size="-1">Organization</font></th>
<th align="center"><font size="-1">Class #</font></th>
<th align="center"><font size="-1">Description</font></th>
<th align="center"><font size="-1">Limit N/Y?</font></th>
<th align="center"><font size="-1">Age Limit</font></th>
</tr>
<tr>
<td><input type="text" name="org" size="6"></td>
<td><input type="text" name="clnum" size="3"></td>
<td><input type="text" name="cldescr"></td>
<td>No:<input type="radio" name="agelim" value="no" checked>
Yes:<input type="radio" name="agelim" value="yes"></td>
<td><input type="text" name="agereq" size="10"></td>
</tr>
<tr>
<td colspan="5" align="center"><input type="submit" name="submit" value="submit">
<input type="reset"></td>
</tr>
</table>
</fieldset>
</form>
<?
}
?>
</body>
</html>
<?
// end of script
?>Pat