Solved

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

Posted on 2015-01-28
2
54 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
2 Comments
 
LVL 82

Accepted Solution

by:
Dave Baldwin earned 500 total points
Comment Utility
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 108

Expert Comment

by:Ray Paseur
Comment Utility
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

763 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now