Hi!

Im currently trying to make a social website of a kind.
I got the login, registration, userpage, profile TINYMCE editor working.

But there is one thing im really struggling with, and that is;
How do i let other users visit other users?

When the user log's in, they're redirected to the user.php page.
I tried to just simply write user.php?id=6 in the url bar, but that did obviously not work, and i still was on my own profile page.

I don't really understand what i have to do either to get this working.
If anyone had the time and knowledge to help me out, i would really appreciate it!

Thx in advance!

user.php?id=6

to work you must make a coding in your page called
user.php
use $_GET["id"] (this will get id of the user you visit) and make a "SELECT" mysql_query to get this user info from your database and display it. :)

P.P> Here is sample:

<?php
include_once(YOURCONFIGfile.php);

if($_GET["id"]=="") { echo "ERROR: THERE IS NO SELECTED USER!"; die(); }
else
{
$html=""; //this will be our html code for output
$id = $_GET["id"];
$sql= "SELECT * FROM USERSTABLE WHERE id='".$id."'";
$res=mysql_query($sql);
while($row=myslq_fetch_array($res)){
$html.="Username: ".$row["username"]."<br>Email".$row["email"];
}
echo $html;
}
?>

This is only sample code.. it depends on your site and database structures, how it will look for you.

If you want a better sample please provide us with your database structure and how you include your config files (for database connection and etc..)

Ahh, i see, i will take a look over the code and read about the $_GET function so i can understand it.
Thank you, i really appreciated it! :)

I became a little confused when trying to understand the code with mine.
If you could take a quick look at my structure, i would be gratefull.

http://pastebay.com/137192
Password: mariuslikeris

If you use already user.php for personal page I think it will be best to create new page called users.php which to be your users view page.
Other way if you want to use the same user.php is to set current code to be when $_GET["id"]is equal to nothing

if($_GET["id"]=="") { current page code }
else { new code as the example which I gave you }

The $_GET[] is getting info from page url entered . its reading this way

page.php?STRING1=VALUE1&STRING2=VALUE2&STRING3=VALUE3

this url will provide you with gets like this :

$_GET["STRING1"] = VALUE1;
$_GET["STRING2"] = VALUE2;
$_GET["STRING3"] = VALUE3;

In inputs form this is claled method="get"
its good only if you use it for display pages. Its not good offer for login or other forms where you have protected data as password, mail or other personal data

Ahh, i think i got it now!
Thank you so much for helping out!
:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.