Jump to content


Photo

Quite a few Booleans…


  • Please log in to reply
1 reply to this topic

#1 Dodge

Dodge
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 01 September 2006 - 11:45 AM

Hey guys, I’m new to PHP/MySQL and I was hoping you’d be able to give me some guidance on a particular matter.

I’m designing a registration form for my website in which I want users to be able to select from a list of US states which they are available to work in. This could be more than one. Whenever I have encountered this before I have simply used checkboxes and recorded, along with the user_id, which items the user selected as Booleans in a `states` equivalent table. Obviously it wouldn’t be appropriate, nor I imagine efficient to check for each boolean per State.

Is there another way I could do this?

One last thing… what is the best way to handle “required” fields? At the moment I have been doing something like:

//Check if user has entered an email
if(!$_POST['email']) {
die('Error: Email field was blank');
}

for each field. Is there a way to combine all the checks in every field, and still have the error report the exact field that was left empty?

Thanks for all your help,

#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 01 September 2006 - 02:15 PM

Well, in theory, you could bitmask the states, since it's a fixed number, but I'm not sure if I even like that suggestion.  As far as the required fields, you'll have to "check" each one, though you could define them in advance and just iterate through them.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users