Search code examples
phpheaderrefresh

PHP header and refresh not working


My server running in PHP 5.2.9, When I using refresh and header functions it's not working. Here is my code

header("location: index.php");

header( "Refresh: 0;" );

Previously I'm working in a different server, It's working correctly. How can I solve this problem?

this is my complete code

if($_POST['sign_in'])
{
    $email = $_POST['email'];
    $password = $_POST['password'];
    $sql = "SELECT * FROM tbl_members WHERE m_email='$email' and m_password='$password'";
    $res = mysql_query($sql);
    $count = mysql_num_rows($res);
    if($count==1)
    {
        session_register("email");
        header("location: index.php");
    }
    else
    {
        $sql = "SELECT * FROM tbl_temp_members WHERE email='$email'";
        $res = mysql_query($sql);
        $count = mysql_num_rows($res);
        if($count==1)
        {
            echo "Login unsuccessful,Account still not activated";  
        }
        else
        {
            echo "Login unsccessful";
        }
    }
}

Solution

  • Location and Refresh both require an absolute URI (and it's "Location" instead of "location").

    Try this one:

    header('Location: http://absolute.uri/file.ext');
    

    If that does not help, check my answer for any "strange" PHP problem ;)