hi...
i want to validate values form a radio button with the database can anyone help ...
<?PHP
$class = "";
$errorMessage = "";
$num_rows = 0;
session_start();
function name()
{
echo $_SESSION['name'];
}
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
$class = $_POST["class"];
//connection to database
if ($db_found) {
$SQL = "SELECT * FROM classes WHERE class= '$class' " ;
$result = mysql_query($SQL);
$num_rows = mysql_num_rows($result);
if ($result) {
if ($num_rows > 0) {
header ("Location: abc.html");
}
else {
print "Error ";
}
}
else {
$errorMessage = "this is not ur class";
}
mysql_close($db_handle);
}
else {
$errorMessage = "Error logging on";
}
}
?>
<html>
<form name="input" action="welcome.php" method="post">
<h1> WELCOME <?PHP name(); ?></h1>
<table border=1>
<tr>
<td><input type="radio" name="class" value="<?php $_SESSION['class1'] ?>" >
</td>
<td><?php echo $_SESSION['class1']; ?></td>
</tr>
<tr>
<td><input type="radio" name="class" value="<?php $_SESSION['class2'] ?>" >
</td>
<td><?php echo $_SESSION['class2']; ?></td>
</tr>
</table>
<p align="center"><input type="submit" value="OK" /></p>
</form>
</html>