我正在使用標頭功能根據特定條件定位到另一個頁面。我正在監視一個郵箱,並且代碼將根據發件人地址重定向到另一個頁面。除一個標題外,所有標題都在運行如果發件人不屬於任何現有的羣組,我想將其重定向到new.php。但它不是重定向。我無法弄清楚爲什麼。請幫幫我。php重定向到另一頁
<?php
session_start();
$server = '{server}INBOX';
$username = '[email protected]';
$password = 'password';
require_once '../swift/lib/swift_required.php';
include('connection.php');
$connection = imap_open($server,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error());
$_SESSION['connection']=$connection;
$result = imap_search($connection,'UNSEEN');
if($result) {
rsort($result);
foreach($result as $email_number)
{
$header = imap_headerinfo($connection, $email_number);
$fromaddr = $header->from[0]->mailbox . "@" . $header->from[0]->host;
$query = "select * from usergroup where email='$fromaddr'";
$_SESSION['fromaddr']=$fromaddr;
$result1 = mysql_query($query) or die($query."<br/><br/>".mysql_error());
while($line=mysql_fetch_array($result1,MYSQL_ASSOC))
{
$email=$line['email'];
$group=$line['group'];
if(mysql_num_rows($result1) == 1){
if($group == 1){
header("Location: facilitator.php");
}
elseif($group == 2){
header("Location: learner.php");
}
}
elseif (mysql_num_rows($result1) == 0) {
header("Location: new.php");
}
}
}
}
elseif (!$result)
{
echo "No unread messages found";
}
?>
請編輯並修復您的縮進。弄清楚你的嵌套是很麻煩的。 –