Solved

PHP Problem with if/then and redirect statement. I can seem to get it to work

Posted on 2015-01-28
2
60 Views
Last Modified: 2015-01-28
     <?php
$result = 6;

if ($result == 5) { 
  header("Location: staffonly2.php");
}
elseif ($result == 6) {
  header("Location: boardonly2.php");
}
elseif ($result == 7) {
    header("Location: eoconly2.php");
}
else {
    echo "<h3 class='clients'>Sorry you don't have the proper user level </h3<br />";
}
?>

Open in new window

0
Comment
Question by:Monte2256
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 40576249
If you have Any white space before the opening PHP tag, it will be sent to the browser and prevent any header statements from working.
// you have
     <?php
// should be
<?php

Open in new window

0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 40576629
0

Featured Post

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question