Creating User Profiles using PHP

Morning All
I want to create a user profile from scratch using PHP, I want a user to be able to register for an account and then when they register to be able to access their profile page and see the values that they put in, for example:

Username: Test 1 etc.

My only problem is I’m not sure where to start, however I would like to make a guess that I would first of all need to create the forms for the user to fill in which will then go into the MYSQL database, and once its in there use a select statement, to retrieve the values.

But how do I set-up the PHP script, that’s the bit I’m stuck on.

If anyone can help me with this, or point me in the right direction that would be brilliant.

Thanks

Are you familiar with using sessions? This will help with the actual login.

The actual profile part is quite easy, you have a HTML form with the fields you want to use, and the PHP script to add the values into the database.

Then, after the user is logged in, you query the database for the details for the user with ID as the user’s $_SESSION[‘id’].

I’m non to familiar with them, I’ve only used them the once, and I’m rather rusty.

Ok, well to start off then you need to read the manual about sessions.

Once you’ve done that, you need to think of a suitable mysql Database Table design. Make sure it includes:
UserID
Username
Password (MD5)
Email
Name

Then, add all the fields to include in the profile.

When the profile form has been sent off, you grab the $_POST variables, and run them in an Insert query.

So, when the user is logged in, you set a session, containing a boolean variable to declare the user as logged in, one holding their username and one holding the userid.

Then to get the results from the query page, use something like:

<?
$q = mysql_query("SELECT field1, field2, field3, ect FROM users WHERE userId = ".$_SESSION['userid']);
$row = mysql_fetch_array($q);
echo "<table>";
foreach($row as $key=>$value){
      echo "<tr><td>".$key."</td><td>".$value."</td></tr>";
}
echo "</table>";
?>

Hope that helps,
Jake Arkinstall