Page 1 of 1

Problem with header

Posted: Mon Jan 26, 2004 1:46 pm
by orangeapple
Hi guys !

Have a problem with header. This is a part of my code :

Code: Select all

<?php
 else {

  
     {

    $sql_passe_check = "SELECT * FROM passe WHERE login='$login' and passe='$passe'";
    $result_passe_check = mysql_query($sql_passe_check);
    $passefound = mysql_num_rows($result_passe_check);
    
    while ($row = mysql_fetch_array($result_passe_check))
                  {
                            $privilege=$row['privilege'];

                             }


     //if checkbox not checked (=password)
     if ($changecheck != "1")
      {
        if ($passefound < 1) {
        echo $html1;
        echo '<br /><div align="center"><br /><br /><img src="../media/sign_warning.jpg" width="70" height="70" border="0"><br /><font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" size="3" color="white"><b>Password not correct !<br />Please go back and try again.</b><br /><br /><br /><br /><br /><a href="clients.html"><img src="../media/sign_back.jpg" width="40" height="40" border="0"></a><br /><br /><br /><br /><br /><br /><br /><br /><br /><div>';
        echo $html2;
        exit;
         }


        else {
         //echo $privilege;
         //exit;
        if ($privilege = 1){

header("Location: norestric1.php");
}
        if ($privilege = 2){

header("Location: norestric2.php");
}
        if ($privilege = 3){

header("Location: norestric3.php");
}
        

        exit;
        }

      }

?>
I know that $privilege is properly extracted from the DB because i can echo it.
But with the "if" and "header" conditions, the file redirects always on norestric3.php whatever the value of $privilege is.

Who can explain me what is wrong ?

Thanks !

Posted: Mon Jan 26, 2004 1:51 pm
by xisle
if ($privilege == 1) would work better...

Posted: Mon Jan 26, 2004 2:14 pm
by orangeapple
:oops: thanks !

...and what would be the syntax, if i want to send the variable to norestric1.php ?

i have seen this code somewere in this forum :

Code: Select all

<?php

header("Location: norestric1.php?$privilege==1"); 

?>
but it doesn't work...

Posted: Mon Jan 26, 2004 2:16 pm
by markl999
?privilege=1

And norestric1.php will have to check for $_GET['privilege'] unless you have register_globals On.

Posted: Mon Jan 26, 2004 2:25 pm
by xisle
if ($privilege == 1){
header("Location: norestric1.php?privilege=1");
}

call variable as $priviledge if register_globals is off, else call as $_GET['priviledge']

Posted: Mon Jan 26, 2004 2:28 pm
by orangeapple
Ok, i have :

Code: Select all

<?php

header("Location: norestric1.php?$privilege=1"); 

?>
and this is my norestric1.php file :

Code: Select all

<?php
$privilege=$_GET['privilege'];
echo $privilege;
?>
but it still doesn't work

Posted: Mon Jan 26, 2004 2:31 pm
by orangeapple
sorry, i made a mistake with $privilege.

Now it works !

Thanks a lot !