SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Member
    Join Date
    Jan 2013
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Complex PHP Registration Form - Help needed please.

    Hi Guys,

    New here and have tried searching but can't seem to find what I'm after.

    Basically I want to create a registration form for a website using PHP and MySQL. The form needs to have all the standard fields like:

    Username
    Password
    Name
    DOB
    Email

    But I also want to have a couple of extra questions in the form, these are:

    Gender - Now am I right in thinking I should use ENUM for this with the values ('m','f') ??

    My next two are the ones that I'm totally stuck on, I want to have one question in the form that has a drop down box as the choices, for example:

    Q. How often to you exercise?
    Then the answers: 1 a week, 2 week, 3 a week, 4 or more a week

    The other one is I'd like to have check boxes as the possible answers.

    Now, I'm struggling to figure out where to go here, I have my page built with PHP and the form inside it, and I'm happy to build the table in MySQL but I don't know what to set the values for those two answer categories as? Am I right in thinking that the answers need to be selected from a different pre-built table with the choices defined? If so, how do I do so and then save the selected choices in the "users" table that will store the data for my new registered user?

    I hope I've made sense?

    Many thanks in advance guys!

  2. #2
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    69 Post(s)
    Tagged
    0 Thread(s)
    Welcome to SitePoint!

    The question I'm going to ask to better answer you is this;

    What do you want to be able to DO with the data?
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.

  3. #3
    SitePoint Member
    Join Date
    Jan 2013
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi StarLion,

    Thanks for replying!

    Ok, so for the one that is (in my head) a drop down selector, once the data has been submitted by the user and they've registered. I essentially want to be able to run queries and select only the users who chose "2 a week" or run a query that selects only the people that chose "5 or more" etc

    Does that make sense?

    I guess I'm just wanting to know how the best way to use PHP and MySQL to record information selected from a drop down box, into my "users" table so that I can in future, run queries based on their responses.

    I hope I'm making sense!

    Thanks again.

  4. #4
    SitePoint Member imsas's Avatar
    Join Date
    Feb 2011
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you expect to have multiple selections for the checkox question I would recommend keeping the values in an array, receive that array on the other end and loop through it to save into your database..
    ___________________________________________________________________
    IMSAS Background Check - Background Check API
    PeopleSearchWorld.com - People Search
    fuzwire.com - Job Search

  5. #5
    SitePoint Zealot 2ndmouse's Avatar
    Join Date
    Jan 2007
    Location
    West London
    Posts
    196
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jonnyjohnson View Post

    Q. How often to you exercise?
    Then the answers: 1 a week, 2 week, 3 a week, 4 or more a week
    I don't understand why you want to provide check boxes for a question that can only have 1 answer. Surely, radio buttons or a drop-down would be preferable. Unless I've got the wrong end of the stick??
    Detect file changes remotely. SimpleSiteAudit is an early
    warning anti-hacker system which sends an alert on detection.

    PHP Find Orphan Files - Finds all the unreferenced files on your site.

  6. #6
    SitePoint Member
    Join Date
    Jan 2013
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi, sorry - yes that's the one that I want for a drop down but am struggling to know how to do it??

    The one with check boxes I'd like to have a choice of answers for example favourite sports and they then select from a list by putting a check in the box.

    But it's the drop down with the exercise habits that I'm really stuck on.

    Thanks,

  7. #7
    SitePoint Zealot 2ndmouse's Avatar
    Join Date
    Jan 2007
    Location
    West London
    Posts
    196
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is this what you mean? The selected value will be parsed with the rest of your form data:

    HTML Code:
      <select name="exercise_habits">
      <option value="Once a week">Once a week</option>
      <option value="Twice a week">Twice a week</option>
      <option value="Three times a week">Three times a week</option>
      <option value="Four or more times a week">Four or more times a week</option>
      </select>
    Detect file changes remotely. SimpleSiteAudit is an early
    warning anti-hacker system which sends an alert on detection.

    PHP Find Orphan Files - Finds all the unreferenced files on your site.

  8. #8
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    69 Post(s)
    Tagged
    0 Thread(s)
    or.. you could just give the values as 1,2,3,4 and not parse them other than to check if they're an INT :P
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •