我需要在提交后重定向页面。登录详细信息失败意味着它需要显示错误消息并重定向到登录表单。请建议我在控制器中完成路径
public function index()
{
$this->load->view('login');
//Here code for other process
}
header('Refresh: 5;url='.$this->index);
我也尝试:
header('Refresh: 5;url=login.php');
答案 0 :(得分:0)
# Function to load specified or default URL.
function load( $page = 'login.php' )
{
# Begin URL with protocol, domain, and current directory.
$url = 'http://' . $_SERVER[ 'HTTP_HOST' ] . dirname( $_SERVER['PHP_SELF']);
# Remove trailing slashes then append page name to URL.
$url = rtrim( $url, '/\\' ) ;
$url .= '/' . $page ;
# Execute redirect then quit.
header( "Location: $url" ) ;
exit() ;
}
像这样使用:
session_start();
$_SESSION[ 'user_id' ] = $data[ 'user_id' ] ;
#calling redirect function
load ( 'home.php' ) ;