retain radio button value on validation fail
okay I'm stuck on something. I built a form with textfields and radio buttons. I have it set up that if a user submits the form, and it fails validation ( they left a field blank ) the form retains the info they entered into the text areas. I want the same thing to happen with the radio buttons but I can't figure out how to make that happen. I don't want a default radio button to be initially displayed...just the one that they chose before they submitted (assuming that validation failed)
<?php
// just initializing my variables here
$msg_to_user = "";
$edate = "";
$time = "";
$desc = "";
$locat = "";
$outpt = "";
$region = "";
?>
<?php
// here is where i am doing my validation checks
if ($_POST['edate'] != "") {
$edate = $_POST['edate'];
$time = $_POST['time'];
$desc = $_POST['desc'];
$locat = $_POST['locat'];
$outpt = $_POST['outpt'];
$region = $_POST['region'];
if (!$time) {
$msg_to_user= '<font color="FF0000">Please enter an event time.</font>';
} else if (!$desc) {
$msg_to_user= '<font color="FF0000">Please enter an event description.</font>';
} else if (!$locat) {
$msg_to_user= '<font color="FF0000">Please enter an event location.</font>';
} else if (!$outpt) {
$msg_to_user= '<font color="FF0000">Please enter output message for email.</font>';
} else if (!$region){
$msg_to_user= '<font color="FF0000">Please choose a region.</font>';
} else {
$msg_to_user= '<font color="FF0000">all done.</font>';
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
date:<br />
<input type="text" name="edate" value="<?php echo $edate; ?>"/><br />
time:<br />
<input type="text" name="time" value="<?php echo $time; ?>"/><br />
description:<br />
<input type="text" name="desc" value="<?php echo $desc; ?>"/><br />
location:<br />
<input type="text" name="locat" value="<?php echo $locat; ?>"/><br />
output to form:<br />
<input type="text" name="outpt"value="<?php echo $outpt; ?>" /><br />
<br />
// these are the radios i want to retain the values if validation fails--------------------------------------------------------------
region:<br />
<label><input type="radio" name="region" value="regionA" />A</label><br />
<label><input type="radio" name="region" value="regionB" />B</label><br />
<label><input type="radio" name="region" value="regionC" />C</label>
<br />
<input type="submit" name="submit" id="submit" value="Submit" />
</form>
<?php echo $msg_to_user; ?>
</body>
</html>