header location php issues

here’s my code:

<?php 

    require("common.php"); 

    unset($_SESSION['user']); 
     session_destroy(); 

    header("Location: login.php"); 


    ?>

in my localhost, it works fine and redirect me to the login page.

but when i upload it to my web server, the header didnt work.

my login page doesnt directed when user log in. but the session was already started.

here’s my login code:

<?php 


    require("common.php"); 


    $submitted_username = ''; 


    if(!empty($_POST)) 
    { 

        $query = " 
            SELECT 
                id, 
                username, 
                password, 
                salt, 
                email 
            FROM users 
            WHERE 
                username = :username 
        "; 


        $query_params = array( 
            ':username' => $_POST['username'] 
        ); 

        try 
        { 

            $stmt = $db->prepare($query); 
            $result = $stmt->execute($query_params); 
        } 
        catch(PDOException $ex) 
        { 

            die("Failed to run query: " . $ex->getMessage()); 
        } 


        $login_ok = false; 


        $row = $stmt->fetch(); 
        if($row) 
        { 

            $check_password = hash('sha256', $_POST['password'] . $row['salt']); 
            for($round = 0; $round < 65536; $round++) 
            { 
                $check_password = hash('sha256', $check_password . $row['salt']); 
            } 

        if($check_password === $row['password'])
            { 
                $login_ok = true; 
            } 
          if($login_ok) 
        { 

            unset($row['salt']); 
            unset($row['password']); 


            $_SESSION['user'] = $row; 

         header("Location:form_menu.php"); 

        } 
        else 
        { 

            echo("<font color=red>Login Failed. Icorrect Password </font>"); 


            $submitted_username = htmlentities($_POST['username'], ENT_QUOTES, 'UTF-8'); 
        }

        }
    }

?> 

is there anyone knows how to resolve this problem? Is there a problem with my web server?

Leave a Reply

*

Hire Me
Follow Me!
Search
Most Popular Articles & Pages
Because your vote is Important
Sorry, there are no polls available at the moment.
Categories