2012-09-12 68 views
-2

我實現了一個簡單註冊頁面,用戶已簽署了必須將其重定向到感謝頁面後,這裏是我的代碼,它返回一個空白頁PHP頭不能重定向

' 保存.PHP '

if($mail->Send()) {} 

    unset($_SESSION['GENRE_REQUEST']); 

    } 
    header('Location:thanku.php'); 
     exit(); 
    } 
    else 
     { 
     header('Location:thanku.php'); 
     exit(); 
     } ' 

thanku.php

<tr> 
     <td align="center" valign="top"><b>Thank You for Registering With us.</b> <br /> 
     <br />please activate your profile by clicking on the activation link sent to your email address.<br/> 
     </td> 
    </tr> 'a 
         ' 
+3

打開錯誤報告。並告訴錯誤。 – itachi

+0

有兩件事:通過在'header()'調用之前放置'die('test')',確保你的'save.php'程序正在執行重定向發生的行。然後,確保你的'thanku.php'頁面被調用,清除所有內容並將'test'文本放在裏面。這樣,你會知道錯誤發生的地方。 – user1477388

+1

根據你發佈的帖子,你有一個'}'在第一行中刪除最後一個 – Breezer

回答

0

這將是有助於查看更多的代碼。另外,如果你的頭文件(「Location:somenewpage.php」)調用失敗,PHP應該會發出某種錯誤。你的php設置中是否打開了display_errors(至少在你的開發環境中)?這將有助於您瞭解腳本發生了什麼問題。

0

嘗試這樣

if($mail->Send()) { 
    session_destroy(); 
    header('Location:thanku.php'); 
} 
else 
{ 
    header('Location:thanku.php'); 
} 
+0

unset()不會完全破壞會話。 – FirmView

+0

我複製粘貼他的代碼我沒有看到 並重新形成代碼 – AboQutiesh

+0

其他{回聲「發送郵件的錯誤」;} – FirmView

1

嘗試,

if($mail->Send()) { 
    header('Location:thanku.php'); 
    exit(); 
}else{ 
    echo "Oops! there was some error in sending the mail"; 
} 

在thanku.php頁,

<?php 
    session_start(); 
    session_unset(); 
    session_destroy(); 
    $_SESSION = array(); 

    echo "Thanks message"; 

?>