Hi all,
My code lists items based on the logged in users id. when listed these items have an edit function.
When the use clicks edit, the url holds the id for that item.
My problem is that its possible to change the url to show details of something thats not theirs
all have a unique id(pk), and owner id(fk).
I want some session security to check thats the owner id is the same as the user id, and if not say access denied. My include looks like this but doesnt work.
i know im close, just cant see the wood for the trees
<?php
session_start();
echo "i am propsec.php" . "<br>";
$emailsec = $_SESSION['user_email'];
$idsec = $_SESSION['user_id'];
$host="localhost"; // Host name
$username="un"; // Mysql username
$password="pw"; // Mysql password
$db_name="db"; // Database name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$sql="SELECT owner_id FROM tbl_sellers";
//$_SESSION['user_type'] = $user_type;
$result=mysql_query($sql);
$row = mysql_fetch_array($result);
$propsec = $row['owner_id'];
echo $idsec;
echo $propsec;
if ($idsec != $propsec) {
echo "NOT allowed" . "<br>";
}else {
echo "Allowed" . "<br>";
}
// If result matched $myusername and $mypassword, table row must be 1 row
//if (!$checkemail = $emailsec) {
// echo "You are not authorised to view this record/page. Very naughty of you";
//}else{
// exit();
?>