-3

speaking of last else of my code it does not direct my login page to index.php ? do you think the problem is header() function?

    if (empty($_POST)===false){
    $username = $_POST['username'];
    $password = $_POST['password']; 

        if(empty($username)=== true || empty($password)=== true){
            $errors[] = 'You need to enter a user name and password';
        }else if(user_exists($username)===false){
            $errors[] = 'we can\'t find that username. Have you registed?';
        }else if(user_active($username)===false){
            $errors[] = 'You have\'t activated your account ! please check your email and active it';
        }else{
            $login = login($username,$password);
            if($login === false){
                $errors[] = "That username/password combination is not correct";
            }else{                  
                $_SESSION['id'] = $login;
                header('Location:index.php');
                exit();
            }
        }       

        print_r($errors);
    }

?>
Bhavin Rana
  • 1,554
  • 4
  • 20
  • 40
user1836957
  • 427
  • 2
  • 9
  • 24
  • 2
    Enable error_reporting and find out (google the error message). โ€“ mario Mar 30 '13 at 07:18
  • 1
    are you sure u dont have any print function before? or associated with that 'login' in case? โ€“ Mayukh Roy Mar 30 '13 at 07:22
  • Try setting the `header()` location to an absolute path, `header("Location: http://www.website.com/index.php");`, instead of the relative path. from the manual [php.net/manual/en/function.header.php](http://www.php.net/manual/en/function.header.php) - `Note: HTTP/1.1 requires an absolute URI as argument to ยป Location: including the scheme, hostname and absolute path...` โ€“ Sean Mar 30 '13 at 07:29

1 Answers1

0

if you want to check header() function works or not. first remove all the if-else conditions and than header() function will definitely work. and than give if-else condition one by one and echo or print some values there for check response.

Bhavin Rana
  • 1,554
  • 4
  • 20
  • 40
ajay
  • 1,560
  • 2
  • 13
  • 16