Session problem
Posted: Sun Nov 20, 2005 2:50 pm
Sessions is not registering.
Login page:
Page that logs user in:
The file top.php begins with the required session_start(); Any idea on why session_register('admin_set'); isn't working?
Login page:
Code: Select all
<?php
include("./../top.php");
include("./../navigation.php");
$admin = $_SESSION['admin_set'];
if(empty($admin)) {
echo "<font><form action=\"login.php\" method=\"POST\"><center>Username:<br><input type=\"text\" name=\"username\"><br>Password:<br><input type=\"password\" name=\"password\"><br><br><input type=\"submit\" value=\"Login\"></form></font>";
} else {
echo "Logged in";
}
include("./../bottom.php");
?>Code: Select all
<?php
$user = $_POST['username'];
$pass = $_POST['password'];
if(empty($user)) {
include("./../top.php");
include("./../navigation.php");
echo "<font><center>Please go back and enter an username</center></font>";
include("./../bottom.php");
die();
}
if(empty($pass)) {
include("./../top.php");
include("./../navigation.php");
echo "<font><center>Please go back and enter a password</center></font>";
include("./../bottom.php");
die();
}
$pass = MD5($pass);
include("./../con.php");
$query = "SELECT * FROM `main_admins` WHERE `username` = '$user' AND `password` = '$pass'";
$result = mysql_query($query) or die(mysql_error());
$rows = mysql_num_rows($result);
if($rows == 0) {
include("./../top.php");
include("./../navigation.php");
echo "<font><center>Wrong username or password. Please go back and try again</center></font>";
include("./../bottom.php");
die();
} else {
session_register('admin_set');
header("location:index.php");
}
?>