mercredi 1 mai 2019

Check Uncheck in PHP Form

I tried:

<?php
if(isset($_POST['submit']))
{
    echo $_POST['Privilege_Question_Name'];
    $Privilege_Question_Query = (($_POST['Privilege_Question_Name'] == "Privilege_Question_Value") ? 'Y' : 'N');
    echo $Privilege_Question_Query;
    exit();
}
?>

<form method="post"  action="" >
          <span class="float-right">Question Settings&nbsp;&nbsp;
          <input type="checkbox" name="Privilege_Question_Name" id="Privilege_Question_Id" value="Privilege_Question_Value"/></span>
          <br />
          <input type="submit" class="btn btn-lg btn-info" name="submit" value="Submit">
          </form>

If the form is checked, it works properly. But if the form is not checked then there's a notice:

Notice: Undefined index: Privilege_Question_Name




Aucun commentaire:

Enregistrer un commentaire