Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Oct 2010
    Posts
    31
    Thanks
    2
    Thanked 0 Times in 0 Posts

    So confused, setting up a user account page

    Ok, so I have the code written to allow someone to come on my site, and sign up, and then log in. But now the nightmare begins, and I cant figure this out.

    Once they are logged in, how do I allow them to enter information (think customizing profiles), and have it specific to them? How do I ensure that they cannot view other peoples information? I mean I understand the whole crud thing, but I just dont know how to learn how to implement it?

    Where can I go to learn?

    Any information is helpful and appreciated.

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    What are you using to keep your user logged in? Sessions? Something else?

    If you use sessions, then set a session variable containing a unique identifier for the person logged in. For example:

    PHP Code:
    $_SESSION['user_id'] = 12345
    Typically you'd store your users in a database table (MySQL probably), and typically you'd have this user_id as a unique primary key for your users table.

    Now it's simply a matter of selecting data from (and updating data to) your table using this unique ID, such as:

    PHP Code:
    $query "SELECT * FROM users_table WHERE user_id = {$_SESSION['user_id']}";
    $result mysql_query($query);
    if (!
    $result) {
        die(
    "Query error! query: $query<br>Error:".mysql_error());
    }
    $userData mysql_fetch_array($result); 

  • #3
    New Coder
    Join Date
    Oct 2010
    Posts
    31
    Thanks
    2
    Thanked 0 Times in 0 Posts
    That in and of itself was very helpful. One other thing is how would you setup the table so that people can enter a bunch of information?

  • #4
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Quote Originally Posted by totesmagotes View Post
    That in and of itself was very helpful. One other thing is how would you setup the table so that people can enter a bunch of information?
    One column at a time.

    If you are new to database design, you have a wealth of general information out on the interwebs to study. Google keywords like "database design tutorial" or "mysql basics", stuff like that. You can also grab a book or two on the subject from your library or Amazon or a book store, etc. This is a massive area of study and good database design is a learned skill that takes a lot of practice and experience to become proficient in.


  •  

    Posting Permissions

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