SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast ParfaitMacaron's Avatar
    Join Date
    Mar 2013
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Registration & Login Form

    Hi,

    I need to create a register form and a login form for my users of the system.

    I have identified the tables in MySQL database.

    There are two different types of my users in my system.

    The first type of user has access to all parts of the system (can add member, edit member, etc)
    The second type of user are users of the system but they can only raise a request within the system (cannot add/edit members).

    For my registration form, I am thinking to have the users log in via their email address as that will definitely be unique and of course, a password.

    How do I create the registration form so that I can have two different types of users within my system at sign up?

    I want to have a drop down box which says something like...

    Select user type:

    then have the options drop down like "user type 1", "user type 2", "user type 3"

    Currently in my MySQL database, I have 2 tables, one for the first user group and the second for the second user group. How do I link it up so that when new users register, I am able to have their details in one place/table listing their member_id, followed by email address and password fields (I am planning to use md5 plus salt).

    Also, the details I need for user group 1 and user group 2 are different (don't require some fields needed in the other such as gender for example).

    Thank you.

  2. #2
    SitePoint Enthusiast
    Join Date
    Mar 2011
    Posts
    70
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    You could query the database looking for the user types available.

    This would return user type data in an array of objects that could then be used to populate a select dropdown.

    Code PHP:
    <?php
        $stmt = $pdo->prepare("SELECT user_type_id, user_type_title FROM user_types");
        $usertypes = $stmt->fetchAll(PDO::FETCH_OBJ);
    ?>
    <select>
    <?php foreach($usertypes as $type) {
         echo "<option value='{$type->user_type_id}'>{$type->user_type_title}</option>";
    }
    ?>
    </select>

    You would need to change this to match the format of the data that is returned from the database but it should give you a general idea of one way you could accomplish this.

  3. #3
    SitePoint Enthusiast ParfaitMacaron's Avatar
    Join Date
    Mar 2013
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you very much, Jeremy.

    Do you think this method would also work?

    To have 2 sign up pages, one for my user type 1 and the other for my user type 2 (which will also have 3 sub-categories [drop down list options] for the user type 2)?

    Quote Originally Posted by JeremyC View Post
    You could query the database looking for the user types available.

    This would return user type data in an array of objects that could then be used to populate a select dropdown.

    Code PHP:
    <?php
        $stmt = $pdo->prepare("SELECT user_type_id, user_type_title FROM user_types");
        $usertypes = $stmt->fetchAll(PDO::FETCH_OBJ);
    ?>
    <select>
    <?php foreach($usertypes as $type) {
         echo "<option value='{$type->user_type_id}'>{$type->user_type_title}</option>";
    }
    ?>
    </select>

    You would need to change this to match the format of the data that is returned from the database but it should give you a general idea of one way you could accomplish this.

  4. #4
    SitePoint Enthusiast
    Join Date
    Mar 2011
    Posts
    70
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    You can do it a thousand different ways, which ever is better for you and those who will use the system. If you find it better for now to have two different forms than you can do that and maybe go back and switch it around when you are more comfortable with php.

  5. #5
    SitePoint Enthusiast ParfaitMacaron's Avatar
    Join Date
    Mar 2013
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you for your help. Much appreciated!

    Quote Originally Posted by JeremyC View Post
    You can do it a thousand different ways, which ever is better for you and those who will use the system. If you find it better for now to have two different forms than you can do that and maybe go back and switch it around when you are more comfortable with php.


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
  •