如何在PHP中重定向/发送? [重复]

This question already has an answer here:

I am working on login functionality.

So what I want to do is, on form submission from login.php if details are correct it should go to home.php else it should go back to login.php.

My login processing is on process.php. But I don't know how to redirect/dispatch to appropriate page from process.php.

</div>

Use header function like this:

header('Location: login.php');
exit;

But don't print any html output before calling header function else it will result in an error.

header('Location: http://someweb.com'); will redirect the user.

Try something like this :

<?php
session_start();
//do some login processing

if(login === true){
    exit(header('Location: home.php'));
}else{
    //Extra marks set a reason why failed
    $_SESSION['error'] = 'Some error about why it failed';
    exit(header('Location: login.php'));
}
?>

exit(header('Location: *')); is what your after.