Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8591201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:28:21+00:00 2026-06-11T23:28:21+00:00

This seems like it should be simple enough but I’m having a little trouble.

  • 0

This seems like it should be simple enough but I’m having a little trouble.

I have an index page which is both the login page and the main content page, depending on whether or not a session variable is set.

I’ve tried using JavaScript which is echoed from PHP to handle redirects but it looked sloppy and takes a little bit of time, so I switched to using header(“location: abc.php”). The problem with using that for the index page is that it doesn’t work after output is sent. I’ve also tried using a meta tag to refresh the page but that doesn’t work in all browsers.

What’s the best way to handle this situation?

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T23:28:22+00:00Added an answer on June 11, 2026 at 11:28 pm

    You can use any of them. However, header("location: abc.php") will not work after sending response! The work around is simple. Use output buffering.

    <?php
    ob_start()
    
    //here goes many lines of your wonderful php code blocks
    
    //now send the header based on your logic
    header("location: abc.php")
    
    ob_end_flush()
    

    Please check the official docs for more info

    Update:
    You can consider the suggestion of @zerkms. If you really need to silently redirect to other page, do that before sending any outputs using header() function. However, if you want to show that you are redirecting him/her, you can use javascript as you were using! For the latter, you can also use Meta Refresh

    <meta http-equiv="refresh" content="5;URL='http://example.com/'">
    

    ob_start() will be helpful for this. Because, you will probably show many things on the page and then tell that he/she will be redirected momentarily. The above example will redirect user to example.com in 5 seconds.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It seems like it should be simple enough, but im having trouble wrapping my
This seems like it should be so simple, but apparently it isn't. I have
Seems like this should be simple enough but for whatever reason I am unable
This seems like it should be simple enough, but I can't seem to get
This seems like it should be really simple, but I'm unable to figure this
This seems like it should be very simple but I can't get it to
Seems like this should be simple, but powershell is winning another battle with me.
This feels like it should be pretty simple, but not much seems to be
This seems like it should be fairly simple, but for some reason I can't
This seems like it should be easy, but I can't quite find an explanation

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.