I'm trying to use PHP to redirect to a page 5 secs after an action is done. I've searched up how to use header for this but want to get more info on incorporating base_url() into the code, so I won't need to change this script multiple times on different servers.
Code:
$url=base_url().'page_I_want_to_go_to'
header('Refresh: X; URL=$url');
This does redirect me to a link, but the url is not the url I was indicating with base and page I want to go to.
Edit to:
$url=base_url().'page_I_want_to_go_to'
header('Refresh: 5; URL=' . $url);
Do you have something configured inside the config file. Check the configuration of the framework that uses. For example, in codeigniter the configuration file is in /application/config/config.php
$config['base_url'] = 'my_page';
Change the bottom line to "double quotes", PHP wont substitute variables that are in single quotes.
$url=base_url().'page_I_want_to_go_to'
header("Refresh: X; URL=$url");
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.