brabus
08-19-2003, 01:55 AM
Hi all,
i'm a newbie in php. quite dizzy in solving this session thingy. So, here's my logincheck script -> to check whether user id & password matched. if matched, status will be setted to 1, and u can see what will happen from the code below. i got no problem to login & i can protect all the pages which is need to protected from the other user.
<?php
$status = authenticate($uid, $pwd);
if ($status == 1)
{
session_start();
session_register("SESSION");
session_register("SESSION_UNAME");
$SESSION_UNAME = $uid;
header("Location: main-all2.php");
exit();
}
else
{
header("Location: login1.php");
exit();
}
function authenticate ($user, $pass)
{
$db="MyDatabaseName";
$con=mysql_connect("localhost","","") or die ("no connection");
$qwery="Select * from admin where uid='$user' and pwd='$pass'";
$result=mysql_db_query($db,$qwery,$con) or die ("sql cannot be executed");
if (mysql_num_rows($result) == 1)
{
return 1;
}
else
{
return 0;
}
}
?>
but the problem is, i can't destroy session created in the system. here's my script for logout part;
<?php
session_start();
session_destroy();
header("Location: login1.php");
?>
if i run this script..i'll get this error msg;
Warning: Session object destruction failed in c:\apache\htdocs\capexonlinesystem\logout.php on line 2
so...anybody out there can help me to solve this problem???
tq in advance.
:confused:
i'm a newbie in php. quite dizzy in solving this session thingy. So, here's my logincheck script -> to check whether user id & password matched. if matched, status will be setted to 1, and u can see what will happen from the code below. i got no problem to login & i can protect all the pages which is need to protected from the other user.
<?php
$status = authenticate($uid, $pwd);
if ($status == 1)
{
session_start();
session_register("SESSION");
session_register("SESSION_UNAME");
$SESSION_UNAME = $uid;
header("Location: main-all2.php");
exit();
}
else
{
header("Location: login1.php");
exit();
}
function authenticate ($user, $pass)
{
$db="MyDatabaseName";
$con=mysql_connect("localhost","","") or die ("no connection");
$qwery="Select * from admin where uid='$user' and pwd='$pass'";
$result=mysql_db_query($db,$qwery,$con) or die ("sql cannot be executed");
if (mysql_num_rows($result) == 1)
{
return 1;
}
else
{
return 0;
}
}
?>
but the problem is, i can't destroy session created in the system. here's my script for logout part;
<?php
session_start();
session_destroy();
header("Location: login1.php");
?>
if i run this script..i'll get this error msg;
Warning: Session object destruction failed in c:\apache\htdocs\capexonlinesystem\logout.php on line 2
so...anybody out there can help me to solve this problem???
tq in advance.
:confused: