In the if statement, go to another page

How do I go to another page in PHP? Via require or fopen?

if ($row_login['password'] != $_POST['password'])
    echo 'Не верный пароль';
else {    
    require('page.php')
}
 0
php
Author: Nicolas Chabanovsky, 2011-11-13

4 answers

In my opinion, in general, it is correct, but you can also include - th. And fopen(): it is possible and so, only hemorrhoids and the code will be more, well, like this is not done.

 0
Author: AlexGreekk, 2011-11-14 19:09:12

There is such a function header.

header() used for sending raw HTTP-caps. See the HTTP/1.1 specification for information about HTTP headers.

 4
Author: nail_gizatullin, 2014-08-06 08:08:15

I usually use

header("Location: http://www.example.com/");

This is both more correct and convenient.

 3
Author: Artem, 2011-11-14 06:23:31
  1. header('Location: _URL_'); exit;
  2. echo '<script>location.replace("_URL_");</script>'; exit;

The second option is non-kosher, but it works when you need to transfer it without saving the page in the history. Or when the hiders have already been sent out.

 2
Author: ling, 2011-11-14 06:32:26