i am trying to create a user profile page,and what i want right is how to echo the users information from the database to display in a profile page once they login from the login page,but the problem is that will echo The user ID is not defined.ilease i need help anyone can help me fix my code am new to php and sql.
profile.php
<?php
include('db.php');
?>
<!DOCTYPE html">
<html>
<head>
<title>Profile of an user</title>
</head>
<body>
<div class="content">
<?php
//We check if the users ID is defined
if(isset($_GET['id']))
{
$id = intval($_GET['id']);
//We check if the user exists
$sql = mysql_query('SELECT fst, las, uid, pass,sts,ocp FROM users WHERE id="'.$id.'"');
if(mysql_num_rows($sql)>0)
{
$res = mysql_fetch_array($sql);
//We display the user datas
?>
This is the profile of "<?php echo htmlentities($res['fst']); ?>" :
<table style="width:500px;">
<tr>
<td class="left"><h1><?php echo htmlentities($res['fst']); ?></h1>
Email: <?php echo htmlentities($dnn['las']); ?><br />
This user joined the website on <?php echo htmlentities($res['uid']); ?></td>
</tr>
</table>
<?php
}
else
{
echo 'This user dont exists.';
}
}
else
{
echo 'The user ID is not defined.';
}
?>
</div>
</body>
</html>
login.php
<?php
include 'db.php';
$uid = $_POST['uid'];
$pass = $_POST['pass'];
$sql = "SELECT * FROM users WHERE uid='$uid' AND pass='$pass'";
$result = mysqli_query($conn,$sql);
if($row = mysqli_fetch_assoc($result)){
header("Location: profile.php");
}else{
echo "invalid username or password";
}
?>