2017-04-11 54 views
0

我從模態輸入數據,並且表單操作在控制器上,如果它是真的/不是會話數據,我想發出警報。這樣,PHP重定向最近的頁面

$rules = [ 
      'required' => [ 
       ['name'],['description'] 
      ] 
     ]; 

     $validate = Validation::check($rules,'post'); 

if(!$validate->auth){ 
      $this->session->set_userdata('error', 'error!'); 
       redirect('recentpagegoeshere'); 
      } 

如何重定向到最近的頁面,我無法使用header('location:...')redirect('to controller')因爲頁面是基於最近的位置

+0

你是什麼意思_「因爲頁面是基於最近的位置」 _你的最後一句話? – Mikey

+0

@Mikey表單在template.blade.php(頁腳部分)上,因此用戶可以在網頁上的任何地方輸入數據,因爲它在模板上。 – Willy

回答

0

找到了答案

header('Location: ' . $_SERVER['HTTP_REFERER']); 
0

我知道你可以用JS解決方案重定向:

echo '<script>window.location="http://your-url-here"</script>'; 

您也可以嘗試使用html標籤:

echo '<meta http-equiv="refresh" content="0;URL=your-url-here">'; 
+0

我不能使用這個,因爲我不知道「URL」在哪裏。因爲該網址是基於最近的頁面 – Willy