2016-04-28 39 views
-1

我有一個問題,當用戶已經註冊我回去與瀏覽器上的按鈕,這個頁面不重定向我,我有一個代碼,以便當你輸入一個註冊用戶將其發送到特定的網站。 提出了「該頁面無法顯示」 沒有我重定向我,雖然我有一個代碼,這轉回php代碼是錯誤的

if (isset ($ _ SESSION ['email'])) 
    { 
    header ("location: sesion.php"); 
    exit(); 
} 

是什麼問題

+6

是真的有這個空間? '__ SESSION' –

+2

當你在瀏覽器中點擊時,瀏覽器取回緩存頁面而不是新頁面 –

回答

0

你有2個問題。首先,頁面通常由瀏覽器緩存。這可以通過將頁面設置爲不cahce(以下方法之一不需要全部完成)來解決。

在PHP在頁面頂部:

session_start(); 
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); 
header("Cache-Control: post-check=0, pre-check=0", false); 
header("Pragma: no-cache"); 

在.htaccess:

<filesMatch "\.(html|htm|js|css)$"> 
    FileETag None 
    <ifModule mod_headers.c> 
    Header unset ETag 
    Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate" 
    Header set Pragma "no-cache" 
    Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT" 
    </ifModule> 
</filesMatch> 

其次你的代碼有額外的空間:

if (isset($_SESSION['email'])) { 
    header("location: sesion.php"); 
    exit(); 
} 
+0

ohh我的上帝:(當我把代碼特別退出(); 頁面沒有加載,不通過不顯示我消息即向下的頁面不記錄給用戶就好像在讀取第一個代碼時停止 :(:(:(( –

+0

)你試圖在session.php中運行這個任務,並且它正在創建一個無限循環? –

+0

你需要有session_start();作爲第一行代碼。確保沒有空間或任何東西 –

0

我有它 這是我的代碼在頂部

i have it 
 
this is my code in the top 
 
[code]<?php 
 

 
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); 
 
header("Cache-Control: post-check=0, pre-check=0", false); 
 
header("Pragma: no-cache"); 
 
session_start(); 
 
//================problema 
 

 
if (isset($_SESSION['email'])) { 
 
    header ("location: sesion.php"); 
 
    exit(); 
 
} 
 

 
//================problema 
 

 
//pregunta si existe el pass segundo del formulario con esto no puede entrar a la web por el link si no se esta registrando 
 
if(!isset($_POST['rpass'])){ 
 
header('Location: ../../index.php'); 
 
exit(); 
 
}[code]

+0

的手冊中,這是我告訴你要做的,它完美的工作?爲什麼把第二個答案,而不是檢查我的? –