#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    42
    Rep Power
    2

    Php radio button


    Hi,

    I am having issue with FormS.php. If i dont select t or f then submit, it does not echo "Blank" instead it echos "False"

    If i dont select t or f, why it does not print out "blank"?

    Please help.

    ------------------------
    1 Form.php
    <form name="lab5" method="post" action="FormS.php">


    <table align = "center" border="1" >

    <tr> <td> Q1 </td> <td> SQL stands for Structured Query Language.</td> <td> <Input type = 'Radio' Name ='questionr' value= 'true'
    >T <Input type = 'Radio' Name ='question' value= 'false' >F</td> </tr>

    <tr><td colspan=6 align='right'><Input type = "Submit" Name = "Submit1" Value = "Select a Radio Button"></td></tr>
    </table>
    </form>


    2

    FormS.php



    <?PHP


    if (isset($_POST['Submit1'])) {

    $selected_radio = $_POST['question'];



    if ($selected_radio == 'true') {

    echo "True";

    }



    else if ($selected_radio = 'false') {

    echo "False";

    }

    else
    {
    echo "blank";

    }

    }

    ?>
  2. #2
  3. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,957
    Rep Power
    1045
    Hi,

    you have an assignment
    PHP Code:
    $selected_radio 'false' 
    instead of an equality check
    PHP Code:
    $selected_radio == 'false' 

IMN logo majestic logo threadwatch logo seochat tools logo