The content in this section is similar to the content in the previous section. It is even simpler than the content in the previous section, because there is only one checkbox.
In the same way as in the previous section, if you do not select this option, $ _ Post won't contain any information about this checkbox, even the key, so we need to create it manually.
That is, (terms is the name value of checkbox)
If (! Isset ($ _ post ['terms']) {$ _ post ['terms'] = '';}
Then add it to $ expected and $ require.
Then, add the error message. If you do not check this box, you cannot continue:
1 <input type = "checkbox" name = "Terms" id = 'term' value = 'aglock'> I have read and understood the risks and agree to register 2 3 <? PHP if (in_array ('terms', $ missing) {?> 4 <SPAN class = "Waring"> Please agree to the terms before continuing </span> 5 <? PHP }?>
Dealing with multiple-choice form fields (2)-handling single checkboxes