Hi guys and gals,
I have a problem with inserting loged in user id in to article table,
I used $_REQUEST [id] and $_GET [id] both didnt work, spent 3 hours on it.
really need help
here is my session variables for loged in users. from login.php
session_start();
$_SESSION[‘id’] = $id;
$_SESSION[‘username’] = $username;
$_SESSION[‘password’] = $password;
$_SESSION[‘isAdmin’] = $isAdmin;
Here is my hedaer.php where session controls the pages
session_start();
require_once ‘…/connect.php’;
require_once ‘…/inc/functions.php’;
// If session variable is not set it will redirect to login page
if(!isset($_SESSION[‘username’]) || $_SESSION[‘isAdmin’]!=1){
$_SESSION[‘message’] = “You dont have permission to see this page!”;
header(“location: …/error.php”);
exit;
}
No, that’ll just probably give parse errors. You seem to be mixing up checking whether the session variables exist, and assigning them values. I also don’t think you should store the password in a session variable, but that’s a different thing for later.
Here is the soluton how to solve it.
for newbies, I had problem with login.php it was posting all infos exept user_id because of bind variables,
I needed to ad id to sql querry.
working perfect now.
querry: $sql = "SELECT username, password, type, id FROM users WHERE username = ?";
bind variables :
$stmt->bind_result($username, $hashed_password, $type, $id);
Thanks
for answers and ideas @droopsnoot