I have login script already. i have two database one is users and another one is reference in both user_name is common. In this if a user login and search the refid means that user datas onle possible to retrieve. for others datas they cant access. i wrote the below code but it display all user datas. kindly help me
Code: Select all
<?php
session_start();
if (!$_SESSION["user_name"])
{
// User not logged in, redirect to login page
Header("Location: login.php");
/ }
// Member only content
// ...
$con = mysql_connect('localhost','root','');
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("login", $con);
$user_name = $_POST['user_name'];
$query = "select * from reference,users where reference.user_name=users.user_name and reference.refid='$refid'";
$result = mysql_query($query) or trigger_error('MySQL encountered a problem<br />Error: ' . mysql_error() . '<br />Query: ' . $query);
while($row = mysql_fetch_array($result))
{
echo $row['refid'];
echo $row['origin'];
echo $row['dest'];
echo $row['date'];
echo $row['exdate'];
echo $row['user_name'];
}
echo "<p><a href=\"logout.php\">Click here to logout!</a></p>";
?>
<html>
<form method="post" action="final.php">
Ref Id:<input type="text" name="refid">
<input type="submit" value="submit" name="submit">
</html>