Solved

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

Posted on 2015-01-28
2
55 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 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 108

Expert Comment

by:Ray Paseur
ID: 40576629
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

930 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

11 Experts available now in Live!

Get 1:1 Help Now