它給人錯誤的單選按鈕沒有在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