radiobutton php controller example

Solutions on MaxInterview for radiobutton php controller example by the best coders in the world

showing results for - "radiobutton php controller example"
Daniella
09 Mar 2017
1<form action="result.php" method="post">
2  Answer 1 <input type="radio" name="ans" value="ans1" /><br />
3  Answer 2 <input type="radio" name="ans" value="ans2"  /><br />
4  Answer 3 <input type="radio" name="ans" value="ans3"  /><br />
5  Answer 4 <input type="radio" name="ans" value="ans4"  /><br />
6  <input type="submit" value="submit" />
7</form>
8  
9PHP code:
10
11<?php 
12$answer = $_POST['ans'];  
13if ($answer == "ans1") {          
14    echo 'Correct';      
15}
16else {
17    echo 'Incorrect';
18}        
19?>