I'm creating a social network script using PHP/MySQL. Everything is working fine. Homepage,Profile, edit profile etc. But the Profile page has URL - http://www.localhost/socialnetwork/profile.php.
I have 5 dummy users and When profile is accessed using their usernames/password. The same URL can be seen on browser.
But I want something like -
URL - http://www.localhost/socialnetwork/profile.php?u=testuser.
Where 'u' can be a unique user Id in database. How to implement it ? Here's my code -
<?php
include("includes/session.php");
include("includes/database.php");
include("includes/user.php");
include("includes/functions.php");
if(!$session->is_logged_in()) { redirect_to("login.php");}
?>
<?php
$user_id = $_SESSION['id'];
// - Here's What I have added - But nothing changes. The URL is same.
if(isset($_GET['id'])){
$uid = $_GET['id'];
}
$sql = "SELECT * FROM users WHERE id = '$user_id' LIMIT 1";
$result = $database->query($sql);
while($record = $database->fetch_array($result)){
$fname = $record['fname'];
$lname = $record['lname'];
$email = $record['email'];
$sex = $record['sex'];
$password = $record['password'];
$phone = $record['phone'];
$birthday = $record['birthday'];
$display = $record['dp'];
$bio = $record['bio'];
}