The PHP code gets the value of the radio button in the form: (The radio button lets us select only one, there is a "checked" property, which is used by default, which is the default value each time we refresh our page.) )
Cases:
<form name= "MyForm" action= "" method= "POST" >
Gender:
<input type= "Radio" name= "Sex" value= "male" checked/> male <input name= "Sex" type= "Radio" value= "female"/> Female <input Type= "Submit" name= "Submit" value= "Submission"/></form><?phpecho "Your choice is:"; echo $_post["sex"];? >
If you choose a male, then the value is "male", if you choose a female, then the value is "female."
The PHP code gets the value of the check box: (check box is able to let us go to the multi-select, they exist at the same time, in order to facilitate the value we will name to an array.) )
The format is:
<input type= "checkbox" Name= "chkbox[]" value= "Chkbox1"/>
Method: The Count () function is used in the return page to calculate the size of the array, combined with a For loop statement, to output the selected check box value.
Cases:
<form action= "" Name= "Form1" method= "POST" >
The number you like:
<input type= "checkbox" Name= "mrbook[]" value= "1"/>1<input type= "checkbox" Name= "mrbook[]" value= "2"/>2 <input type= "checkbox" Name= "mrbook[]" value= "3"/>3<input type= "checkbox" Name= "mrbook[]" value= "4"/>4 <input type= "Submit" name= "Submit" value= "Commit"/></form><?phpif ($_post[' Mrbook ']!=null) { echo " The number you selected is: "; for ($i =0; $i <count ($_post[' Mrbook "), $i + +) { echo $_post[' Mrbook '] [$i]." "; }}? >
We have to learn to use arrays to solve our problems!!!!