Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 5th, 2003, 12:48 AM
Registered User
 
Join Date: Jul 2003
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Redirecting logged in users

Dear All,
        I have an Asp background but am new to php. I have a system which supports two types of users General & Administrator. They will be logging in from a single page. The user id will be verified with the database to determine whether he is a general or admin user.
        According to that he will redirected to his respective home page. In ASP it can be easily achieved by Response.Redirect / Server.Transfer command. But I am unable to find a suitable command in php.

        Also I tried using header("Location: URL"); command but it turned out to be unsuitable, as I need to use HTML content in the page before it.(This is because I need to show the error messages generated by the Database queries like invalid password etc. in a formatted output.)
        But the header command's pre-requisite seems to be not to send any html code before it.
        Can this problem be solved at all. Any help will be appreciated.

                Thanks in Advance
                            Zicaden

 
Old September 5th, 2003, 09:09 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If you're displaying content to the user, it doesn't make sense to redirect right away, which is what the header("Location: URL") method does for you. The user wouldn't have any chance at reading your error messages.

I suggest you use javascript and/or a meta-refresh tag if you'd like to redirect the user to a different page after one page is loaded for a given amount of time.


Take care,

Nik
http://www.bigaction.org/
 
Old September 5th, 2003, 11:22 PM
Registered User
 
Join Date: Jul 2003
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Dear Nikolai,
              I thank you for your response. Could you please provide me with a sample code for the equivalent in Javascript or Meta/Refresh. Actually I know vbscript only.

                                        Zicaden.

 
Old September 6th, 2003, 02:41 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Search google for several examples of each:

  http://www.google.com/search?q=javascript+redirect
  http://www.google.com/search?&q=meta+refresh


Take care,

Nik
http://www.bigaction.org/





Similar Threads
Thread Thread Starter Forum Replies Last Post
redirecting users t0r3ad0r ASP.NET 1.0 and 1.1 Professional 1 October 5th, 2006 10:32 PM
Determine logged on users markw707 Access 1 January 21st, 2005 01:59 AM
Redirecting Users anshul Pro PHP 1 April 3rd, 2004 04:31 PM
Redirecting logged on Users fletched PHP How-To 1 March 25th, 2004 06:42 PM
Help with redirecting users Sach Classic ASP Databases 1 January 16th, 2004 12:29 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.