CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: Re: [terrykhatri531] How to implement a checkbox that will send data to db: Edit Log



Zhris
Enthusiast

Jul 9, 2014, 8:09 PM


Views: 34294
Re: [terrykhatri531] How to implement a checkbox that will send data to db

Hi Terry,

You shouldn't even have to run that query, you already know there are just two choices, true or false.

Its purely personal preference, but I would stick to using 0 and 1 as values, they are much easier to handle in Perl since they represent false and true, whereas the strings 'f' and 't' both represent true. This will be especially helpful when it comes to validating the user supplied input i.e. you should never directly store the user supplied value in the database when dealing with booleans.

When you come to implementing a single checkbox, remember if its checked, it will supply the value to the script, otherwise it will supply nothing (undefined), you'll need to handle this appropriately regardless of what values you choose to represent true and false.

Regards,

Chris


(This post was edited by Zhris on Jul 9, 2014, 8:19 PM)


Edit Log:
Post edited by Zhris (Enthusiast) on Jul 9, 2014, 8:10 PM
Post edited by Zhris (Enthusiast) on Jul 9, 2014, 8:11 PM
Post edited by Zhris (Enthusiast) on Jul 9, 2014, 8:18 PM
Post edited by Zhris (Enthusiast) on Jul 9, 2014, 8:19 PM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives