Jump to content

Archived

This topic is now archived and is closed to further replies.

Immortal55

Question

Recommended Posts

When you make a user system on a website using databases and php, and you want users to have a 'user profile' does a page essentially have to be created when they register with the website, or what? If a page is created when they register, how do i go about doing that?

Share this post


Link to post
Share on other sites
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]does a page essentially have to be created when they register[/quote]
No... You store there profile infomation in a database, then call there data on a [i]profile.php[/i] page.

Share this post


Link to post
Share on other sites
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]does a page essentially have to be created when they register[/quote]
No... You store there profile infomation in a database, then call there data on a [i]profile.php[/i] page.

Share this post


Link to post
Share on other sites
I would suggest that you have a "members" page that is sorted some way - even if it just sorts them by id descending. Each member's username would be a link to something like /profile.php?user="usernamehere"..
Then you could populate sections of that page by getting the member's info from the database.

Something like:


[code]$sql = mysql_query("SELECT * FROM members WHERE username='{$_REQUEST['user']}'");[/code]

then you could simply use a while loop to make the user's info into simply variables:

[code]while($row = mysql_fetch_assoc($sql)){

//this next line will make all the array variables into normal variables - if you had a "last_name" field in the database you could now call it simply by using $last_name
stripslashes(extract($row));

echo $username;
echo $last_name;
}
[/code]

This is just an example of how to do it, not full blown code as I have neither the time, or your database setup etc... Anyway, if you need any more help, just ask :)

-austen

Share this post


Link to post
Share on other sites
Alright, well if I was to do this, would it be possible for somebody to view the members page, even when not logged on? If they could view the persons page, how would it be possible for the profile.php page to load certain users information?

Share this post


Link to post
Share on other sites

alright, so if I wanted to have links to user profiles from my db, where the table with the info is titled users, and in the table the names i want displayed are under 'uname' then would my script look like this:

[code]
<?

$conn = db_connect();
if (!$conn)
    return false;
    
    $sql = mysql_query("SELECT * FROM users WHERE
        uname = '{$_REQUEST['user']}'");
        
    while($row = mysql_fetch_assoc($sql){
    stripslashes(extract($row));
    
    echo '<a href="/profile/profile.php?user='.$uname.'>'.$uname.'</a>';
    
}

?>
[/code]

if anything is wrong, please help me out.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.