Hello all.
I am working on an admin side to my site, and want the admin to login through a form and using sessions, stay logged in.
What i have so far is this:
login.php
<?php
$user = $_REQUEST['username'];
$pass = $_REQUEST['pass'];
$password = md5($pass);
include('connection.php');
$query = "SELECT * FROM members WHERE Username = '$user'";
$result = mysql_query($query, $dbc) or die('<b>Unable to Find User</b><br>'.$user);
$display = mysql_fetch_array($result);
$dbUser = $display['Username'];
$dbPass = $display['Password'];
$group = $display['Group'];
if($dbUser == $user && $dbPass = $password){
session_start();
session_register('login');
session_register('group');
$_SESSION['login'] = 'true';
$_SESSION['group'] = $group;
Then I display a page which redirects to my index.php page.
index.php
<?php
include('./scripts/connection.php');
include('./scripts/display/news.php');
include('./scripts/display/events.php');
$page = $_GET['id'];
if(!isset($_GET['id'])){
function curdbView(){
echo('Nothing to show');
}
function editdbItem(){
echo('Nothing to edit');
}
function deldbItem(){
echo('Nothing to delete');
}
function addItem(){
echo('No Category to add to');
}
showPage();
}
if($page == '1'){
include('scripts/stories.php');
showPage();
}
if($page == '2'){
include('scripts/events.php');
showPage();
}
if($page == '3'){
include('scripts/links.php');
showPage();
}
if($page == '4'){
include('scripts/members.php');
showPage();
}
if($page == '5'){
include('scripts/downloads.php');
showPage();
}
function showPage(){
if($_SESSION['login'] != 'true' && $_SESSION['group'] != 'admin'){
// Cut out extra content
}
else{
// Cut out extra content
}
Why is it, that when I go to my page, I get the login page (which is what I want) but once I log in, which sets the session, for some odd reason the login page shows again. Any ideas?
Thanks for the help.
~Brett