...

View Full Version : So confused, setting up a user account page



totesmagotes
12-15-2010, 03:16 AM
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.

Fumigator
12-15-2010, 05:01 AM
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:



$_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:



$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);

totesmagotes
12-15-2010, 07:07 AM
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?

Fumigator
12-15-2010, 03:45 PM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum