2011-01-14 36 views
0

登錄後我想將用戶發回$value
$value用我的代碼生成,打印出來,看起來不錯。
這是一個完整的URL:http://example.com/page.php?id=6

卻忽略了header("Location: ".$value);聲明:

if($iniciando->iniciar()) { 
    if (isset($_SESSION['redirect'])) { 
     $he ="http://funcook.com" . $_SESSION['redirect']; 
     mostrar_notificacion($he); 
     header("Status: 301"); 
     header("Location: " . $he, true, 301); 
    } else { 
     imprimir_sesion_iniciada(); 
    } 
} else { 
    imprimir_formulario_sesion(); 
} 
+0

也許顯示完整的代碼。之後你會做一個「死()」嗎? – 2011-01-14 00:40:45

+0

您在此代碼之前是否打印過任何內容?嘗試exit();在標題() – 2011-01-14 00:41:25

+0

`die`之後`die`不需要重定向工作。打開錯誤,你可能會得到一個標題已經發出警告,馬特建議。 – webbiedave 2011-01-14 00:44:35

回答

2

header("Location x");具有在任何其他輸出發送到瀏覽器中調用。這包括<?php?>標記之外的任何空格。

此外,請確保您也沒有任何打印/回聲語句用於調試目的。

0

我懷疑你使用的是Chrome嗎?

你應該使用更好的重定向代碼,所有的瀏覽器遵循它:

header("Status: 301"); 
    header("Location: ".$URL, true, 301); 
相關問題