PHP链接到个人资料页面

Im new on php, so i need some sugests for following code:

<?php
// Start the session (pretty important!)
session_start();

// Establish a link to the database
$dbLink = mysql_connect('', '', '');
if (!$dbLink) die('Can\'t establish a connection to the database: ' . mysql_error());

$dbSelected = mysql_select_db('', $dbLink);
if (!$dbSelected) die ('We\'re connected, but can\'t use the table: ' . mysql_error());

$isUserLoggedIn = false;  
$query = 'SELECT * FROM users WHERE session_id = "' . session_id() . '" LIMIT 1';  
$userResult = mysql_query($query);  
if(mysql_num_rows($userResult) == 1) {  
    $_SESSION['user'] = mysql_fetch_assoc($userResult);  
    $isUserLoggedIn = true;  
} else {  
    if(basename($_SERVER['PHP_SELF']) != 'conectare.php') {  
        header('Location: conectare.php');  
        exit;  
    }  
}  
?>

Upper code verify if user it's logged in or not..

I need to create a profil link, like following:

http://site.com/profile.php?name=NAME-OF-USER

Can someone give me a ideea?

Im newbie on php, so pls understand me..

PS: Please dont tell me to use mysql, pdo and another, i allready know the beneficts, i need only answers for my code..

Thank you !

All you need to do is echo some html:

$username = "foo";
echo "<a href=\"http://site.com/profile.php?name=".$username." \">profile link</a>";

Note: I use \" to escape the "

More information about strings in php: http://php.net/manual/en/language.types.string.php

you simply need to use the get variable

create the link that will be clicked like this

the link that will be clicked on home page or any other page

 <?php
 $username='test';//the variable containing the username
 echo'<a href="mysite.com/profile.php?user='.$username.'">
      The link redirecting to profile page
      </a>';
 ?>

the address bar will turn something like this www.mysite.com/profile.php?user=test

then on the profile page

<?php
$username_selector=$_GET['user']//in this case the value got from the link clicked is test
//then just select the necessary data using the variable storing the value got from th link clicked
?>