Hi Red,
Thank you for your help. I was initially using a cookie based login system. After your post I decided to read into the differences between session and cookies and session suits my needs more, so thank you for that.
So here is the code I have added to submit-login.php:
[php]// Retrieve username and password from database according to user’s input
$login = mysql_query(“SELECT * FROM users WHERE (username = '” . mysql_real_escape_string($_POST[‘username’]) . “’) and (password = '” . mysql_real_escape_string(md5($_POST[‘password’])) . “’)”);
// Check rows
if (mysql_num_rows($login) == 1) {
// Grab groupid
$groupid = mysql_query(“SELECT groupid FROM users WHERE (username = '” . mysql_real_escape_string($_POST[‘username’]) . “’)”);
// Set session variables
$_SESSION[‘username’] = $_POST[‘username’];
$_SESSION[‘groupid’] = $groupid;[/php]
Now the login session itself is working as I am logged in on all the pages. However it does not seem to grab the groupid so think I have the above code wrong as getting permission denied. No error logs in apache.
The code for checking is as you gave above.
When echoing out $_SESSION[‘groupid’] it gives me the value of ‘0’ (definitely set correctly in db).
I will keep trying a few things but any help would be much appreciated.
Kind Regards,
egghead0