Jump to content

Creating user pages without ME creating all of them


navybofus

Recommended Posts

Okay I realize that I had a question earlier and it's been under an hour and I am asking another one, but I figured out the last on my own :)

 

Okay *game face*

 

I have a site that you can log in to. Cool. The problem is that everyone that logs in to my site sees the exact same thing. I can't even start to imagine how facebook creates a profile for everyone that signs up. I'm not trying to create a facebook type site, I just want my users to be able to see their own content on a personalized page where they can access stuff that they uploaded.

 

Lemme ASCII art a pic for ya.

____________________________________________________________________

____http://www.example.com/user123______________________________|_GO_|

|  _________                                                        |

|  |        |        Welcome, Johnny Five                          |

|  | Profile |              Time, Date                              |           

|  | Picture |                                                      |

|  |_________|                                                      |

| Last Online: Date                                                  |

|                  _________Uploaded Files:______________________    |

|                File1    ::    Description    ::        Size    |

|                File2    ::    Description    ::        Size    |

|_________________File3    ::    Description    ::        Size____|

 

Anyone have any suggestions or insight on how they do this?

Link to comment
Share on other sites

To begin with Facebook dosen't create each profile one by one :)lol.

 

Also what you are trying to do it common. It is called the get method. Let me give you a breakdown:

 

Database:

Your database will store all your member info (i.e Name,Email,Age,and Etc...). However the main important thing in the database is the ID, you will be using that to call members information out.

 

Table name members

 

ID

Name

Email

Age

1

John Doe

johndoe@johndoe.com

25

2

Jane Doe

janedoe@janedoe.com

25

 

Code:

Now that a little kind of sloppy database design. Next you start coding:


//Gets the Members ID
$id = $_GET['id'];

//Locate the member's info with the ID given
$query = mysql_query("SELECT * FROM `member` WHERE id='$id'");

//See does the member exist
$num = mysql_num_rows($query);

//If the member does not exist shoot an error message out
if($num == 0){echo'Member does not exist';}else{

//Member exist lets pull their info out the database

$row = mysql_fetch_assoc($query);

//Assigning Variables to info that is given
$name = $row["name"];
$email = $row["email"];
$age = $row["age"];

 

Next just create a nice HTML table a display the information i.e:

 


echo"Hello $name <br>
You are $age years old<br>
Your email address is $email<br>
"

 

The code above may have some errors but you should get the general idea.

 

So now lets say you have a roster page and when the use click on their username you should have the link look like the following yoursite.com/profile.php?id=1

 

Since that ID is 1 it will then pull John Doe's information.

 

 

Link to comment
Share on other sites

kk question. This is where my user gets sent to if they have a username and password entered correctly.

 

header("Location: login_success.php");

 

I am supposed to put a variable in there right? To call their specific information? Something like...

 

header('Location: login_success.php?id=' + '$userid');

 

right? The reason I ask is because I am getting an internal server error when I click submit to the login form. I can't get the http://dndpnponline.com/login_success.php?id=1 to show up in my browser and I think it's something to do with trying to put the variable into the address.

Link to comment
Share on other sites

Well I used

header("Location: login_success.php?id=$userid");

and since it's in " " quotes its working. I have heard that the session ID doesn't carry over to new pages. So in the new page I have to call all of their info using their user ID? I am going to put the code that was in the posts above in the user page. This should call the info from the database. I'll have to tweak it a bit and that might not go over well since my coding is bad at the least. I'll keep you guys updated. Thanks for all of the replies. I wish I could give yo guys rep on this forum but so far I haven't been able to find a way to do that.

Link to comment
Share on other sites

Hello,

 

Well its not the right idea to concat the id of the user in the URL for security reasons. I would suggest when user is login on to your website and login is successful you should store id into session variable. Once id is in session variable you can easily access if on another page.

 

For more information about session please go through the following link:-

 

http://www.php.net/manual/en/book.session.php

 

 

Link to comment
Share on other sites

Okay so this doesn't work and I don't think I know enough to know what's wrong.

<? include('db.php');

//Gets the Members ID
$id = $_GET['id'];

//Locate the member's info with the ID given
$query = mysql_query("SELECT * FROM 'users' WHERE id='$id'");

// See does the member exist
$num = mysql_num_rows($query);

// If the member does not exist shoot an error message out
if($num == 0){echo'Member does not exist';}else{

//Member exist lets pull their info out the database
$row = mysql_fetch_assoc($query);

//Assigning Variables to info that is given
$first_name = $row["first_name"];
$last_name = $row["last_name"];
$email_address = $row["email_address"];
$info = $row["info"];
$last_login = $row["last_login"];
}
?>

 

It keeps telling me this "Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in SITE/DIRECTORY/login.php on line 11" Member does not exist

 

Am I using an old tag or something? Or maybe I forgot to define something. I really don't know :(

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.