hi there..
I have a function that checks wheter or not a user has access to certain pages.
The function uses some cookie variables in order to run.
I call this function on top of the pages that need authentication.
If the function failes, then the user is sent to a logon page.
After the user has typed inn username/password, he is redirected to the page he was trying to access.
Problem::
User is beeing looped back to the logon page all the time.
But when I try to use the function on a different page, it works...
Function::
function checkaccess($cook_ab_nr, $cook_password) {
if (!sql_logon()) {
return 0 ;
} // end check logon.
$see = "select abonnent.kode as kode
from abonnent, tilgang
where tilgang.ab_nr = '$cook_ab_nr'
AND tilgang.ab_nr = abonnent.ab_nr
AND tilgang.password = '$cook_password'
AND abonnent.datout > NOW()" ;
$see_q = mysql_query($see) ;
$c = mysql_fetch_array($see_q) ;
$match = mysql_num_rows($see_q) ;
if ($c["kode"] != 'gruppeabonnement') {
if ($match == 1) {
return 1 ;
} else {
return 0;
} // End if/else
} else { //
$sql = "SELECT abonnent.kode, tilgang.password from tilgang, abonnent
WHERE ab_nr = $cook_ab_nr
AND password = '$cook_password'
AND abonnent.datout > NOW()" ;
$sql_query = mysql_query($sql) ;
$hit = mysql_num_rows($sql_query) ; // hits
if ($hit == 1) {
return 1; // ett treff. gi tilgang
} else {
return 0 ; // ellers, ikke gi tilgang.
}
}
} // End check user access function.
This is the example that works::
<?
require ("access/member.php") ;
if (!checkaccess($cook_ab_nr, $cook_password)) {
$go = header("location:http://www.havneavisen.net/abonnent/logg.php?side=abonnent/functest") ;
if (!$go) {
echo "damn";
}
} else {
?>
<body>
<font face="arial" size="3">
<b><u><i>
<?
echo "NAH NAH NAH NAH<br><br>
$cook_ab_nr<br><br>
$cook_password" ; ?>
</b></u></i></font>
</body>
<?
} // end
?>