I seem to experiencing difficulty taking the id from the user on profile.php
.
profile.php
PHP:
<?php
session_start();
require 'include/connect.php';
if(!$_SESSION['key']){
header('Location: login.php');
}
$uid = $_GET['id'];
$sql = "SELECT * FROM users WHERE id = '$uid'";
$query = mysql_query($sql);
while($row = mysql_fetch_array($query)){
$user = $row['username'];
}
?>
As you see, when you add to the url with get data (EX:profile.php?id=3
)
you visit the appropriate user's profile; however I want to take the id of the user and extract their information from the database so they view their own profile upon going to profile.php
.(without adding a GET extension)
Question: What method can I use to query using the user's id #? And also, do I need to store a session for this.