{"id":928,"date":"2021-04-06T15:03:28","date_gmt":"2021-04-06T15:03:28","guid":{"rendered":"https:\/\/phptutorial.net\/?page_id=928"},"modified":"2025-04-07T14:16:48","modified_gmt":"2025-04-07T14:16:48","slug":"php-checkbox","status":"publish","type":"page","link":"https:\/\/www.phptutorial.net\/php-tutorial\/php-checkbox\/","title":{"rendered":"PHP Checkbox"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: in this tutorial, you will learn how to use PHP to process a form with one or more checkboxes.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='a-quick-introduction-to-the-checkbox-element'>A quick introduction to the checkbox element <a href=\"#a-quick-introduction-to-the-checkbox-element\" class=\"anchor\" id=\"a-quick-introduction-to-the-checkbox-element\" title=\"Anchor for A quick introduction to the checkbox element\">#<\/a><\/h2>\n\n\n\n<p>A checkbox allows you to select a single value for submission in a form. <\/p>\n\n\n\n<p>To create a checkbox, you use the <code>input<\/code> element with the type <code>checkbox<\/code> as follows:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">input<\/span> <span class=\"hljs-attr\">type<\/span>=<span class=\"hljs-string\">\"checkbox\"<\/span> <span class=\"hljs-attr\">name<\/span>=<span class=\"hljs-string\">\"checkbox_name\"<\/span> <span class=\"hljs-attr\">value<\/span>=<span class=\"hljs-string\">\"checkox_value\"<\/span>&gt;<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>A checkbox has two states: checked and unchecked. <\/p>\n\n\n\n<p>If you check the checkbox and submit the form using the <code>POST<\/code> method, the <code>$_POST<\/code> associative array will contain an element whose key is <code>checkbox_name<\/code> and value is <code>checkbox_value<\/code>.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-keyword\">echo<\/span> $_POST&#91;<span class=\"hljs-string\">'checkbox_name'<\/span>]; <span class=\"hljs-comment\">\/\/ 'checkbox_value'<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>However, if you uncheck the checkbox and submit the form, the <code>$_POST<\/code> won&#8217;t have any element with key <code>checkbox_name<\/code>. It means that the following expression returns <code>false<\/code>:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-keyword\">isset<\/span>($_POST&#91;<span class=\"hljs-string\">'checkbox_name'<\/span>])<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>To check if a checkbox is checked, you can also use the <code><a href=\"https:\/\/phptutorial.net\/php-tutorial\/php-filter_has_var\/\">filter_has_var()<\/a><\/code> function like this:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\"><span class=\"hljs-keyword\">if<\/span>(filter_has_var(INPUT_POST,<span class=\"hljs-string\">'checkbox_name'<\/span>)) {\n     <span class=\"hljs-comment\">\/\/ ...<\/span>\n}<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The <code>filter_has_var()<\/code> function returns <code>true<\/code> if the <code>checkbox_name<\/code> exists in the <code>INPUT_POST<\/code>.<\/p>\n\n\n\n<p>A checkbox has no label by default. Therefore, you should always use a checkbox with a <code>&lt;label&gt;<\/code> element like this:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">input<\/span> <span class=\"hljs-attr\">type<\/span>=<span class=\"hljs-string\">\"checkbox\"<\/span> <span class=\"hljs-attr\">name<\/span>=<span class=\"hljs-string\">\"agree\"<\/span> <span class=\"hljs-attr\">id<\/span>=<span class=\"hljs-string\">\"agree\"<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">label<\/span> <span class=\"hljs-attr\">for<\/span>=<span class=\"hljs-string\">\"agree\"<\/span>&gt;<\/span>I agree<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">label<\/span>&gt;<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><a href=\"https:\/\/phptutorial.net\/playground\/?q=PGlucHV0IHR5cGU9ImNoZWNrYm94IiBuYW1lPSJhZ3JlZSIgaWQ9ImFncmVlIj4KPGxhYmVsIGZvcj0iYWdyZWUiPkkgYWdyZWU8L2xhYmVsPg\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\n\n\n\n<p>In this example, the value of the <code>for<\/code> attribute of the <code>&lt;label&gt;<\/code> element is the same as the value of the <code>id<\/code> attribute of the checkbox. When you associate a label with a checkbox, you can click the label to check or uncheck the checkbox.<\/p>\n\n\n\n<p>Another way to associate a checkbox with a label is to place the checkbox inside the label like this:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">label<\/span>&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">input<\/span> <span class=\"hljs-attr\">type<\/span>=<span class=\"hljs-string\">\"checkbox\"<\/span> <span class=\"hljs-attr\">name<\/span>=<span class=\"hljs-string\">\"agree\"<\/span>&gt;<\/span> I agree\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">label<\/span>&gt;<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In this case, you don&#8217;t need to specify the <code>id<\/code> for the checkbox and the <code>for<\/code> attribute for the label.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='a-simple-php-checkbox-example'>A simple PHP checkbox example <a href=\"#a-simple-php-checkbox-example\" class=\"anchor\" id=\"a-simple-php-checkbox-example\" title=\"Anchor for A simple PHP checkbox example\">#<\/a><\/h2>\n\n\n\n<p>We&#8217;ll create <a href=\"https:\/\/phptutorial.net\/app\/checkbox\" target=\"_blank\" rel=\"noreferrer noopener\">a form with one checkbox and a submit button<\/a>.<\/p>\n\n\n\n<p>First, create the following directory and file structure:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"plaintext\" data-shcb-language-slug=\"plaintext\"><span><code class=\"hljs language-plaintext\">.\n\u251c\u2500\u2500 css\n\u2502   \u2514\u2500\u2500 style.css\n\u251c\u2500\u2500 inc\n\u2502   \u251c\u2500\u2500 .htaccess\n\u2502   \u251c\u2500\u2500 get.php\n\u2502   \u2514\u2500\u2500 post.php\n\u2514\u2500\u2500 index.php<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">plaintext<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">plaintext<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>File<\/th><th>Directory<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td>index.php<\/td><td>.<\/td><td>Contain the main logic that loads get.php or post.php depending on the HTTP request method<\/td><\/tr><tr><td>header.php<\/td><td>inc<\/td><td>Contain the header code<\/td><\/tr><tr><td>footer.php<\/td><td>inc<\/td><td>Contain the footer code<\/td><\/tr><tr><td>get.php<\/td><td>inc<\/td><td>Contain the code for showing a form with a checkbox when the HTTP request is GET.<\/td><\/tr><tr><td>post.php<\/td><td>inc<\/td><td>Contain the code for handling POST request<\/td><\/tr><tr><td>.htaccess<\/td><td>inc<\/td><td>Prevent direct access to the files in the inc directory<\/td><\/tr><tr><td>style.css<\/td><td>css<\/td><td>Contain the CSS code<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id='index-php'>index.php <a href=\"#index-php\" class=\"anchor\" id=\"index-php\" title=\"Anchor for index.php\">#<\/a><\/h3>\n\n\n\n<p>Second, add the following code to the <code>index.php<\/code> file:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-meta\">&lt;?php<\/span>\n\n<span class=\"hljs-keyword\">require<\/span> <span class=\"hljs-keyword\">__DIR__<\/span> . <span class=\"hljs-string\">'\/inc\/header.php'<\/span>;\n\n$errors = &#91;];\n\n$request_method = $_SERVER&#91;<span class=\"hljs-string\">'REQUEST_METHOD'<\/span>];\n\n<span class=\"hljs-keyword\">if<\/span> ($request_method === <span class=\"hljs-string\">'GET'<\/span>) {\n\t<span class=\"hljs-keyword\">require<\/span> <span class=\"hljs-keyword\">__DIR__<\/span> . <span class=\"hljs-string\">'\/inc\/get.php'<\/span>;\n} <span class=\"hljs-keyword\">elseif<\/span> ($request_method === <span class=\"hljs-string\">'POST'<\/span>) {\n\t<span class=\"hljs-keyword\">require<\/span> <span class=\"hljs-keyword\">__DIR__<\/span> . <span class=\"hljs-string\">'\/inc\/post.php'<\/span>;\n}\n\n<span class=\"hljs-keyword\">if<\/span> ($errors) {\n\t<span class=\"hljs-keyword\">require<\/span> <span class=\"hljs-keyword\">__DIR__<\/span> . <span class=\"hljs-string\">'\/inc\/get.php'<\/span>;\n} \n\n<span class=\"hljs-keyword\">require<\/span> <span class=\"hljs-keyword\">__DIR__<\/span> . <span class=\"hljs-string\">'\/inc\/footer.php'<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The <code>index.php<\/code> loads the form from the <code>get.php<\/code> file if the HTTP request method is GET. And it loads the <code>post.php<\/code> file if the form is submitted.<\/p>\n\n\n\n<p>The <code>$errors<\/code> variable is used to store error messages.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id='header-php'>header.php <a href=\"#header-php\" class=\"anchor\" id=\"header-php\" title=\"Anchor for header.php\">#<\/a><\/h3>\n\n\n\n<p>Third, place the following code to the <code>header.php<\/code> file:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"hljs-meta\">&lt;!DOCTYPE <span class=\"hljs-meta-keyword\">html<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">html<\/span> <span class=\"hljs-attr\">lang<\/span>=<span class=\"hljs-string\">\"en\"<\/span>&gt;<\/span>\n\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">head<\/span>&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">meta<\/span> <span class=\"hljs-attr\">charset<\/span>=<span class=\"hljs-string\">\"UTF-8\"<\/span> \/&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">meta<\/span> <span class=\"hljs-attr\">name<\/span>=<span class=\"hljs-string\">\"viewport\"<\/span> <span class=\"hljs-attr\">content<\/span>=<span class=\"hljs-string\">\"width=device-width, initial-scale=1.0\"<\/span> \/&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">title<\/span>&gt;<\/span>PHP Checkbox<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">title<\/span>&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">link<\/span> <span class=\"hljs-attr\">rel<\/span>=<span class=\"hljs-string\">\"stylesheet\"<\/span> <span class=\"hljs-attr\">href<\/span>=<span class=\"hljs-string\">\"css\/style.css\"<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">head<\/span>&gt;<\/span>\n\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">body<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"center\"<\/span>&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">main<\/span>&gt;<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\" id='footer-php'>footer.php <a href=\"#footer-php\" class=\"anchor\" id=\"footer-php\" title=\"Anchor for footer.php\">#<\/a><\/h3>\n\n\n\n<p>Fourth, the <code>footer.php<\/code> file contains the enclosing tags corresponding to the opening tags from the <code>header.php<\/code> file:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-10\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">main<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">body<\/span>&gt;<\/span>\n\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">html<\/span>&gt;<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-10\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\" id='get-php'>get.php <a href=\"#get-php\" class=\"anchor\" id=\"get-php\" title=\"Anchor for get.php\">#<\/a><\/h3>\n\n\n\n<p>Fifth, create a form in the <code>get.php<\/code> file:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-11\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">&lt;form action=<span class=\"hljs-string\">\"&lt;?= htmlspecialchars($_SERVER&#91;'PHP_SELF']) ?&gt;\"<\/span> method=<span class=\"hljs-string\">\"post\"<\/span>&gt;\n    &lt;div&gt;\n        &lt;label <span class=\"hljs-keyword\">for<\/span>=<span class=\"hljs-string\">\"agree\"<\/span>&gt; &lt;input type=<span class=\"hljs-string\">\"checkbox\"<\/span> name=<span class=\"hljs-string\">\"agree\"<\/span> value=<span class=\"hljs-string\">\"yes\"<\/span> id=<span class=\"hljs-string\">\"agree\"<\/span> \/&gt; I agree to the &lt;a href=<span class=\"hljs-string\">\"#\"<\/span> title=<span class=\"hljs-string\">\"term of service\"<\/span>&gt; Term of Service&lt;\/a&gt;&lt;\/label&gt;\n        &lt;small <span class=\"hljs-class\"><span class=\"hljs-keyword\">class<\/span>=\"<span class=\"hljs-title\">error<\/span>\"&gt;&lt;?<span class=\"hljs-title\">php<\/span> <span class=\"hljs-title\">echo<\/span> $<span class=\"hljs-title\">errors<\/span>&#91;'<span class=\"hljs-title\">agree<\/span>'] ?? '' ?&gt;\n        &lt;\/<span class=\"hljs-title\">small<\/span>&gt;\n    &lt;\/<span class=\"hljs-title\">div<\/span>&gt;\n\n    &lt;<span class=\"hljs-title\">div<\/span>&gt;\n        &lt;<span class=\"hljs-title\">button<\/span> <span class=\"hljs-title\">type<\/span>=\"<span class=\"hljs-title\">submit<\/span>\"&gt;<span class=\"hljs-title\">Join<\/span> <span class=\"hljs-title\">Us<\/span>&lt;\/<span class=\"hljs-title\">button<\/span>&gt;\n    &lt;\/<span class=\"hljs-title\">div<\/span>&gt;\n&lt;\/<span class=\"hljs-title\">form<\/span>&gt;<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-11\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\" id='post-php'>post.php <a href=\"#post-php\" class=\"anchor\" id=\"post-php\" title=\"Anchor for post.php\">#<\/a><\/h3>\n\n\n\n<p>Sixth, add the following code to the <code>post.php<\/code> file to sanitize and validate the form data:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-12\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-meta\">&lt;?php<\/span>\n\n<span class=\"hljs-keyword\">if<\/span>(filter_has_var(INPUT_POST, <span class=\"hljs-string\">'agree'<\/span>)) {\n\n    $agree = trim($_POST&#91;<span class=\"hljs-string\">'agree'<\/span>]);\n   \n    <span class=\"hljs-keyword\">if<\/span> ($agree === <span class=\"hljs-string\">'yes'<\/span>) {\n        <span class=\"hljs-keyword\">echo<\/span>  <span class=\"hljs-string\">'Thank you for joining us!'<\/span>;\n    } \n    \n} <span class=\"hljs-keyword\">else<\/span> {\n    $errors&#91;<span class=\"hljs-string\">'agree'<\/span>] = <span class=\"hljs-string\">'To join us, you need to agree to the TOS.'<\/span>;\n}\n\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-12\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\" id='summary'>Summary <a href=\"#summary\" class=\"anchor\" id=\"summary\" title=\"Anchor for Summary\">#<\/a><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use the <code>isset()<\/code> or <code>filter_has_var()<\/code> to check if a checkbox is checked or not.<\/li>\n<\/ul>\n<div class=\"helpful-block-content\" data-title=\"\">\n\t<header>\n\t\t<div class=\"wth-question\">Did you find this tutorial useful?<\/div>\n\t\t<div class=\"wth-thumbs\">\n\t\t\t<button\n\t\t\t\tdata-post=\"928\"\n\t\t\t\tdata-post-url=\"https:\/\/www.phptutorial.net\/php-tutorial\/php-checkbox\/\"\n\t\t\t\tdata-post-title=\"PHP Checkbox\"\n\t\t\t\tdata-response=\"1\"\n\t\t\t\tclass=\"wth-btn-rounded wth-yes-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t\tclass=\"feather feather-thumbs-up block w-full h-full\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> Yes <\/span>\n\t\t\t<\/button>\n\n\t\t\t<button\n\t\t\t\tdata-response=\"0\"\n\t\t\t\tdata-post=\"928\"\n\t\t\t\tdata-post-url=\"https:\/\/www.phptutorial.net\/php-tutorial\/php-checkbox\/\"\n\t\t\t\tdata-post-title=\"PHP Checkbox\"\n\t\t\t\tclass=\"wth-btn-rounded wth-no-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> No <\/span>\n\t\t\t<\/button>\n\t\t<\/div>\n\t<\/header>\n\n\t<div class=\"wth-form hidden\">\n\t\t<div class=\"wth-form-wrapper\">\n\t\t\t<div class=\"wth-title\"><\/div>\n\t\t\t\n\t\t\t<textarea class=\"wth-message\"><\/textarea>\n\n\t\t\t<button class=\"btn btn-primary wth-btn-submit\">Send<\/button>\n\t\t\t<button class=\"btn wth-btn-cancel\">Cancel<\/button>\n\t\t\n\t\t<\/div>\n\t<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>in this tutorial, you will learn how to use PHP to process a form that has one checkbox or multiple checkboxes.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":15,"menu_order":87,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-928","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.phptutorial.net\/wp-json\/wp\/v2\/pages\/928","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.phptutorial.net\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.phptutorial.net\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.phptutorial.net\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.phptutorial.net\/wp-json\/wp\/v2\/comments?post=928"}],"version-history":[{"count":4,"href":"https:\/\/www.phptutorial.net\/wp-json\/wp\/v2\/pages\/928\/revisions"}],"predecessor-version":[{"id":3282,"href":"https:\/\/www.phptutorial.net\/wp-json\/wp\/v2\/pages\/928\/revisions\/3282"}],"up":[{"embeddable":true,"href":"https:\/\/www.phptutorial.net\/wp-json\/wp\/v2\/pages\/15"}],"wp:attachment":[{"href":"https:\/\/www.phptutorial.net\/wp-json\/wp\/v2\/media?parent=928"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}