Note that there are some explanatory texts on larger screens.

plurals
  1. POphp redirecting to another page
    text
    copied!<p>I am using the header function to locate to another page based on certain conditions. I am monitoring a mailbox and the code redirects to another page based on the sender address. All headers are working except one. If the sender does not belongs to any existing group, I wanted to redirect it to new.php. But it is not redirecting. I am unable to figure out why. Please help me.</p> <pre><code>&lt;?php session_start(); $server = '{server}INBOX'; $username = 'aaa@bbb.com'; $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-&gt;from[0]-&gt;mailbox . "@" . $header-&gt;from[0]-&gt;host; $query = "select * from usergroup where email='$fromaddr'"; $_SESSION['fromaddr']=$fromaddr; $result1 = mysql_query($query) or die($query."&lt;br/&gt;&lt;br/&gt;".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"; } ?&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload