2011-06-14 5 views
-3

라디오 버튼을 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> 
+3

endra "작동하지 않음"이란 무엇을 의미합니까? 또한 를 예를 들어''로 바꾸십시오. – Tadeck

+0

예. 그러나 나의 질문은 달랐다. 실수로 나는 이것을 업로드했다. – Gnan

+1

* * (작동하지 않는)? – deceze

답변

3

당신에게 구문 오류가 위에서 언급 한 오류를주고 같은 오류를 제공합니다 :

if ($selected_radio = = 'male') 
        ^^^ 

==이어야합니다.

+0

오 .... thanku @deceze. – Gnan

3

변경 if ($selected_radio = = 'male')에서 if ($selected_radio == 'male')으로 변경하십시오. 등호 (=) 기호는 함께 있어야합니다 (==).

+0

감사 @ 프랑수와 Deschenes – Gnan

관련 문제