Results 1 to 2 of 2

Thread: PHP help...

  1. #1
    Join Date
    Aug 2008
    Posts
    36
    Tokens
    0

    Default PHP help...

    Right i have a login script but when the user logs out i want it to redirect to a new page, not using the html redirection probably header() is the best method.

    I know how to use header's but i just dont know where to place it in this code so that once the user is logged out then it will execute the redirection.

    heres the code:

    PHP Code:
    if($user!="" && $pass!="" && $d!="logout") {
    $mdc mysql_query("SELECT * FROM user WHERE user = '".addslashes($user)."' AND pass = '".addslashes($encrypt_pass)."'"); $usrd mysql_fetch_array($mdc);
    if(
    $usrd[id]!="") {

    $_SESSION[user] = $user$_SESSION[pass] = $pass$lg="ok"
    mysql_query("UPDATE user SET online='".time()."' WHERE id='".$usrd[id]."'");

    } else { 
    session_unset(); $lg=""; }
    } else { 
    session_unset(); $lg=""; } 

  2. #2
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    PHP Code:
    <?php

    if( $user != '' && $pass != '' && $d != 'logout' )
    {

        
    $mdc mysql_query"SELECT * FROM `user` WHERE `user` = '" addslashes$user ) . "' AND `pass` = '" addslashes$encrypt_pass ) . "'" );
        
    $usrd mysql_fetch_array$mdc  );

        if( 
    $usrd'id' ] != '' )
        {

            
    $_SESSION'user' ] = $user;
            
    $_SESSION'pass' ] = $pass;
            
    $lg 'ok'
            
            
    mysql_query"UPDATE `user` SET `online` = '" time() . "' WHERE `id` = '" $usrd'id' ] . "'");

        }
        else
        {
        
            
    session_unset( );
            
    $lg '';
            
        }

    }
    else
    {

        
    session_unset(  );
        
    $lg '';
        
        
    header'Location: logout.php' );
        
    }  

    ?>
    Try that.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •