它给人错误的单选按钮没有在PHP工作
Parse error: parse error in C:\Project1\radio.php on line 12
此代码是给上面提到的错误
<?PHP
$male_status = 'unchecked';
$female_status = 'unchecked';
$var="Default";
if (isset($_POST['Submit1']))
{
//$var="Got set";
$selected_radio = $_POST['gender'];
if ($selected_radio = = 'male')
{
$male_status = 'checked';
}
else if ($selected_radio == 'female')
$female_status = 'checked';
}
?>
<html>
<head>
<title>Radio Buttons</title>
<script>
//document.form1.textBox.value="";
</script>
</head>
<body>
<FORM name ="form1" method ="post" action ="radio.php">
<Input type = 'Radio' Name ='gender' value= 'male'
<?PHP print $male_status; ?>
>Male
<Input type = 'Radio' Name ='gender' value= 'female'
<?PHP print $female_status; ?>
>Female
<P>
<Input type = "Submit" Name = "Submit1" VALUE = "Select a Radio Button">
My cal
<Input type = "Text" Name = "textBox" VALUE = "<?php echo $var ?>">
</FORM>
</body>
</html>
endra你是什么意思的“不工作”?也可以用例如'<?php echo $ var?>'替换'<?php $ var?>'。 – Tadeck 2011-06-14 02:21:45
是的,它的工作。但我的问题是不同的。错误地我已经上传了这一个。 – Gnan 2011-06-14 02:25:26
*什么*(不)工作? – deceze 2011-06-14 02:27:31