How to read if a checkbox is checked in PHP? Last Updated : 29 Oct, 2018 Comments Improve Suggest changes Like Article Like Report Using isset() Function The isset() function is an inbuilt function in PHP which checks whether a variable is set and is not NULL. This function also checks if a declared variable, array or array key has null value, if it does, isset() returns false, it returns true in all other possible cases. This problem can be solved with the help of isset() function. Syntax: bool isset( $var, mixed ) Description: This function accepts more than one parameters. The first parameter of this function is $var. This parameter is used to store the value of variable. Program: html <?php if(isset($_GET['submit'])) { $var = $_GET['option1']; if(isset($var)) { echo "Option 1 submitted successfully"; } } ?> <html lang="en"> <head> <title>GeeksforGeeks Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href= "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <style> .gfg { font-size:40px; font-weight:bold; color:green; } body { text-align:center; } </style> </head> <body> <div class="container"> <div class = "gfg">GeeksforGeeks</div> <h2>Form control: checkbox</h2> <p>The form below contains one checkbox.</p> <form method="get"> <div class="checkbox"> <label><input type="checkbox" name = "option1" value="Option 1">Option 1</label> <label><button name="submit" value='true' class="btn btn-default">SUBMIT</button> </div> </form> </div> </body> </html> Output: Using empty() Function The empty() function is an inbuilt function in PHP which is used to check whether a variable is empty or not. Syntax: bool empty( $var ) Description: This function determine whether a variable is empty or not. Example: html <?php if(!empty($_GET['submit'])) { $var = $_GET['option1']; if(isset($var)){ echo "Option 1 submitted successfully"; } } ?> <!DOCTYPE html> <html lang="en"> <head> <title>GeeksforGeeks Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href= "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"> </script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"> </script> <style> .gfg { font-size:40px; font-weight:bold; color:green; } body { text-align:center; } </style> </head> <body> <div class="container"> <div class = "gfg">GeeksforGeeks</div> <h2>Form control: checkbox</h2> <p>The form below contains one checkbox.</p> <form method="get"> <div class="checkbox"> <label><input type="checkbox" name = "option1" value="Option 1">Option 1</label> <label><button name="submit" value="true" class="btn btn-default">SUBMIT</button> </div> </form> </div> </body> </html> Output: Reference: http://php.net/manual/en/function.isset.php http://php.net/manual/en/function.empty.php Comment More infoAdvertise with us Next Article How to read if a checkbox is checked in PHP? S sarthak_ishu11 Follow Improve Article Tags : Technical Scripter Web Technologies PHP PHP Programs Technical Scripter 2018 +1 More Similar Reads How to check form submission in PHP ? Given a form and the task is to check form submitted successfully or not. Use the PHP program for the backend to check form submission and HTML and CSS to create the form as frontend. Syntax: if (!empty($_POST)) if (isset($_POST['submit'])) Use these two statements to check whether the form submitte 3 min read How to check whether an array is empty using PHP? Arrays are commonly used data structures that can hold multiple values. Sometimes it is necessary to check if an array is empty or not, and it is an important task to avoid errors when working with data. PHP offers several easy and effective ways to check if an array is empty. Below are the most com 3 min read How to Get $_POST from multiple check-boxes ? $_POST is an array of variable names. The program given below illustrates how to write HTML structure for multiple valued checkbox and to get the values of multiple valued checkbox using $_POST in PHP. Note: The name attribute of checkboxes must be the same name and must be initialized with an array 2 min read How to determine if an array contains a specific value in PHP? Determining if an array contains a specific value in PHP involves verifying whether a particular element exists within an array. This task is essential for various programming scenarios, such as searching for user input, validating data, or filtering results based on specific criteria. PHP offers se 2 min read Uppercase Booleans vs. Lowercase in PHP The boolean expresses the truth value. The Boolean represents two possible values: TRUE or FALSE. True can be given a value of 1, and False is given a value of zero. To specify a boolean literal, use the constants TRUE or FALSE. Both are case-insensitive. It means that TRUE is equal to true and FALS 2 min read Like