/    Sign up×
Community /Pin to ProfileBookmark

How To Make Use of Boolean Validator ?

Folks,

How can I make use of the BOOLEAN Validator ?
I saw this:
https://www.php.net/manual/en/filter.filters.validate.php

Do you mind to show me a php example linked to an html form ?
Anyway, here’s my attempt to understand where you make use of this Boolean validator. See, if I understood correctly or not.

PHP

[code]
function validate_integer($value) {
//https://www.php.net/manual/en/filter.filters.validate.php
if(!filter_input(INPUT_POST, “string”, FILTER_VALIDATE_BOOLEAN))
{
echo(“Input is not valid”);
}
else
{
echo(“Input is valid”);
}
return filter_input($value);
}
[/code]

Html

[code]
<form method = ‘POST’ action = “”>
<label for=’tos’>Agree To Tos: Yes</label>
<input type=’check’ name=tos’ id=’yes’>
<br>
<button type=’submit’>Search!</button>
</form>
[/code]

So you use the BOOLEAN validator against html like the above ? Yes or no ?
I mean, would you check, using the Boolean Validator, if a checkbox is checked or not ? Is that why you use the Boolean Validator here ?
I guess there are more reasons to use it. But I want to know some good reasons and see some good html & php code samples.
Do show us a bunch of code samples (both html & php) of different uses where you would use the BOOLEAN Validator here.

Cheers!

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@developer_webauthorJul 18.2021 — @Sempervivum,

Care to chime in ?
Copy linkTweet thisAlerts:
@developer_webauthorJul 23.2021 — @sempervivum

I'd like to see a code sample from you, if you don't mind.
×

Success!

Help @developer_web spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...