Page 1 of 1

PHP - How do I include a checkbox???

Posted: Sat Aug 01, 2009 4:36 pm
by xtk
ok,

I have a checkbox (that asks if you want to add a password) and then a textbox (that allows the user to enter a password if the checkbox is checked)

I would like the php script (say for example x.php) to run said script ONLY IF the checkbox is checked

as in, the PHP script will include the password (of the text of the textbox) as a variable that I can assign to whatever I am doing

Please help, for google has failed me yet again

Regards.

Re: PHP - How do I include a checkbox???

Posted: Sat Aug 01, 2009 5:16 pm
by requinix
xtk wrote:as in, the PHP script will include the password (of the text of the textbox) as a variable that I can assign to whatever I am doing
That's not how it works. You get the password box (empty or not) regardless - you decide whether you want to use it.

Code: Select all

if (isset($_POST["checkbox"])) {
    // checkbox was checked
} else {
    // checkbox was not checked
}
PS: Google works for me.