Using a checkbox to create a variable

Hi all,
I need help understanding how to create a variable using a checkbox, and then having that variable be recognized by a different script. Basically I have a search of company products set up, but I want my users to be able to check a box and have that checked box filter out all products that are custom, and custom products are marked with a ‘3’ in the field product_type in the database table.

The way I want to do this is by adding the following code to my utilities.php script which controls the search feature:

if ($exclude_custom){ $where_filter .= "AND PRODUCT_TYPE != '3'"; }

What I dont understand is how to have the checkbox bring into existence the variable $exclude_custom

I get that I create the checkbox in a form. Do I also define the $exclude_custom in the form? Do I have the action of the form be “utilities.php” and use the “post” method? Does that send the defined variable to the utilities.php file so it can be used by the above if statement?

Any guidance would be great

Thanks!

you should process form and then check if checkbox was checked ,
[php]
if(isset($_POST[‘myCheckBox’])) {
$where_filter .= " AND PRODUCT_TYPE != ‘3’ ";
}
[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service