mercredi 28 mars 2018

if condition not works

i'am student and i have a project to do. I am working for a membership page but this is the issue : whatever the login is, i am always redirected to the admin page.

 <?php
 function logUser() {

  require( './connexion.php' );

    $sql_user = 'SELECT * FROM tgn_users WHERE login="' . $_POST[ 'login' ] . '"';

$req = mysqli_query( $connexion, $sql_user )or die( mysqli_error( $connexion 
 ) );

 if ( mysqli_num_rows( $req ) > 0 ) {

 $row = mysqli_fetch_assoc( $req );

if ( Bcrypt::checkPassword( $_POST[ 'mdp_user' ], $row[ 'mdp_user' ] ) ) {

    if($row['login']='admin'){

        header( 'Location: ../../admin/' );

    }else{

        $_SESSION[ 'nom_user' ] = $row[ 'nom_user' ];
        $_SESSION[ 'prenom_user' ] = $row[ 'prenom_user' ];
        $_SESSION[ 'id_user' ] = $row[ 'id_user' ];
        //$lifetime = 60*60*24*30;
        //setcookie(session_name($_SESSION['nom_user']), session_id($_SESSION['id_user']),time()+$lifetime,'/');
        header( 'Location: ../../profile.php' );
    }

}else {
    $_SESSION[ 'message' ] = "Erreur de log et/ou de pwd";
    header( "Location: " . $_SERVER[ 'HTTP_REFERER' ] );

}
}

 }?>

Aucun commentaire:

Enregistrer un commentaire