简体   繁体   中英

how to redirect in PHP without javascript or Headers

I was wondering if there is any way I can redirect my login page automatically to another page.php without using Javascript at all or headers, because I already try with the last ones, but I need to send some echo before that.

You see, is for a log-in process, after the log-in i wanna be capable of send different users to different page.php according to the type of user this will be, so that will be the propose of this.

I've already checked for this matter before but I can't find a single answer than doesn't suggest the use of headers, or JavaScript.

If you see some other question than actually answer this please link it but first be sure it actually doesn't use JavaScript or headers to do it.

echo '<meta http-equiv="refresh" content="0; url=http://example.com/" />'

在页面的<head></head>部分中回显此内容

Although you have mentioned in the question that you don't want to use headers. Probably because you can't echo a message, But using the header below you can both echo a message and redirect a user to next page.

header( "refresh:5; url=wherever.php" ); //Redirect page after five seconds.
echo 'Redirecting in 5 seconds';

EDIT: Redirect users to different URLs.

$url = 'user_home.php';
if($user == 'admin'){
   $url = 'admin_home.php';
}

header( "refresh:5; url= $url" ); //Redirect page after five seconds.
echo 'Redirecting you to your home in 5 seconds. Please wait.';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM