PHP - How do I include a checkbox???

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
xtk
Forum Newbie
Posts: 10
Joined: Sat Aug 01, 2009 4:28 pm

PHP - How do I include a checkbox???

Post 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.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

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

Post 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.
Post Reply