Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

PHP - if go to one page, else go to another?!?

New Here ,
Dec 30, 2009 Dec 30, 2009

Copy link to clipboard

Copied

I have an if, else statement and I want to go to one page if and another page else.  I can't seem to get it to go the page.  It goes nowhere.  Can someone give me a sample php code how to do this?  Thanks!

TOPICS
Server side applications

Views

2.6K
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Dec 30, 2009 Dec 30, 2009

Rick4209 wrote:

I have an if, else statement and I want to go to one page if and another page else.  I can't seem to get it to go the page.  It goes nowhere.  Can someone give me a sample php code how to do this?  Thanks!

if (isset($_SESSION['MM_Username'])) {

  header ('Location: http://example.com/loggedin.php');

  exit;

} else {

  header ('Location: http://example.com/login.php');

  exit;

}

I suspect if you're going nowhere, it's because there is output before the call to header. For an explanation, s

...

Votes

Translate
LEGEND ,
Dec 30, 2009 Dec 30, 2009

Copy link to clipboard

Copied

LATEST

Rick4209 wrote:

I have an if, else statement and I want to go to one page if and another page else.  I can't seem to get it to go the page.  It goes nowhere.  Can someone give me a sample php code how to do this?  Thanks!

if (isset($_SESSION['MM_Username'])) {

  header ('Location: http://example.com/loggedin.php');

  exit;

} else {

  header ('Location: http://example.com/login.php');

  exit;

}

I suspect if you're going nowhere, it's because there is output before the call to header. For an explanation, see http://kb2.adobe.com/community/publishing/505/cpsid_50572.html.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines