I'm using radio buttons on a form for my website. I am currently trying to write some error checking. If the radio button isn't set when the form is submitted what will $_GET return? I tried echoing it and it appears to be "", but my if statement isn't picking up on it. Is it just not returning a value at all?
2 Answers
Use form method as POST , using GET method in form submit is not good practice . If you are using POST method, you can check like below
if(!isset($_POST['radio_buttonname'])){
//Your error message set here
}
If you are using GET method.Use below code,
if(!isset($_GET['radio_buttonname'])){
//Your error message set here
}
if (empty($_GET['radio_button']) { /* do something */ } else { /* do something */ }radiobutton won't exist in$_POST