CurtWRC
03-06-2008, 11:57 AM
Hi,
I am having some problems with a login system. When the user enters in their username and password, if the username/password is incorrect then they are given an error message. This works fine, however when you choose the correct login details you are taken into the site but you are still asked to login. Below are some code snippets:
<?
session_start();
session_register("username");
session_register("password");
require_once("db_mysql.php");
$q = new DB_Sql;
if(isset($login))
{
$sql="select id from tbl_login where username='$username_frm' and password='$password_frm'";
$q->query($sql);
if ($q->next_record())
{
$username=$username_frm;
$password=$password_frm;
header("Location:admin.php");
exit();
}
else
{
header("Location:login.php?msg=Wrong+Username/Password");
exit();
}
}
?>
function validate($user,$pass) {
if(!isset($user)) {
header("location:login.php?msg=You+Session+has+expired");
}
}
<?session_start();
require_once("db_mysql.php");
$username = $_SESSION['username'];
$password = $_SESSION['password'];
validate($username,$password);
include_once("top_header.php");
$q = new DB_Sql;
?>
Does this make any sense to anyone?
Cheers,
Curt.
I am having some problems with a login system. When the user enters in their username and password, if the username/password is incorrect then they are given an error message. This works fine, however when you choose the correct login details you are taken into the site but you are still asked to login. Below are some code snippets:
<?
session_start();
session_register("username");
session_register("password");
require_once("db_mysql.php");
$q = new DB_Sql;
if(isset($login))
{
$sql="select id from tbl_login where username='$username_frm' and password='$password_frm'";
$q->query($sql);
if ($q->next_record())
{
$username=$username_frm;
$password=$password_frm;
header("Location:admin.php");
exit();
}
else
{
header("Location:login.php?msg=Wrong+Username/Password");
exit();
}
}
?>
function validate($user,$pass) {
if(!isset($user)) {
header("location:login.php?msg=You+Session+has+expired");
}
}
<?session_start();
require_once("db_mysql.php");
$username = $_SESSION['username'];
$password = $_SESSION['password'];
validate($username,$password);
include_once("top_header.php");
$q = new DB_Sql;
?>
Does this make any sense to anyone?
Cheers,
Curt.