-2

I am trying to use header() in my page on real server but it does not work. If I try it in Xammp on localhost it works fine.

if(empty($_POST)===false){
        include_once("db.php");
        $username = $_POST['user'];
        $pwd = $_POST['pwd'];

        $rs = mysqli_query($con,"select *from admin_acc where username = '".$username."'");
        $num_rows = mysqli_num_rows($rs);

        if($num_rows > 0){
        while($rows = mysqli_fetch_assoc($rs))
        {
            $db_username = $rows['username'];
        }

        if($username == $db_username && md5($pwd) == $db_password){
            $_SESSION['username'] = $db_username;

            //Header to Home Page
            header('Location: customers.php');

        }else{
            $wrng_pwd = "Wrong Password!";  
            $msg_type = 1;
        }
        }else{
            $user_nt = "User name not exsit!!"; 
            $msg_type = 2;
        }
    }

So can you please help me?

George Stocker
  • 57,289
  • 29
  • 176
  • 237
abzoghbi
  • 7
  • 2
  • once you check for errors, you'll find out why – Funk Forty Niner Jul 24 '16 at 22:47
  • Okay, can you give me any way that let me debug the error – abzoghbi Jul 24 '16 at 22:51
  • ***You really shouldn't use [MD5 password hashes](http://security.stackexchange.com/questions/19906/is-md5-considered-insecure)*** and you really should use PHP's [built-in functions](http://jayblanchard.net/proper_password_hashing_with_PHP.html) to handle password security. Make sure you [don't escape passwords](http://stackoverflow.com/q/36628418/1011527) or use any other cleansing mechanism on them before hashing. Doing so *changes* the password and causes unnecessary additional coding. – Jay Blanchard Jul 25 '16 at 15:39

1 Answers1

0

I finally find the solution is using java script is more better that php header

for example:

<script type="text/javascript">
window.location.href = 'http://www.google.com';
</script> 

or

<script type="text/javascript">
window.location.href = 'page2.php/';
</script>
abzoghbi
  • 7
  • 2