Forum Moderators: coopster

Message Too Old, No Replies

PHP login redirect to previous page

to redirect to previous page

         

MrFahad

12:10 pm on Feb 14, 2009 (gmt 0)

10+ Year Member



Hello, i want to make a script that will redirect the user to where they was after logging in just like in most forum software.

here is the error:

Notice: Undefined index: login in /Applications/MAMP/htdocs/realestate/includes/session.php on line 23

Warning: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/realestate/includes/session.php:23) in /Applications/MAMP/htdocs/realestate/includes/session.php on line 27

<snipped code dump>

----------------------------------------------------------

me and my friend are trying for days to solve it be keep getting errors

***********************************************************

[edited by: coopster at 5:47 pm (utc) on Feb. 14, 2009]
[edit reason] Charter [webmasterworld.com] [/edit]

coopster

5:50 pm on Feb 14, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



PHP is dumping out an error message (the undefined index) to the browser so when you are attempting to redirect you are getting the second message. You cannot output anything to the browser, including error messages like this, before using the header() function.

Fix the undefined index message and your redirection might work.

MrFahad

6:04 pm on Feb 14, 2009 (gmt 0)

10+ Year Member



the problem how to fix it? I'm kinda new to PHP, if you need any more info about the code please let me know i really need this to be done

thanks and great site by the way ;)

coopster

6:12 pm on Feb 14, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



The problem?

Notice: Undefined index: login in /Applications/MAMP/htdocs/realestate/includes/session.php on line 23

You are using an undefined index called "login" in an array (probably $_SESSION based on the discussion here) on line 23 of the script which is named "session.php" located in the path shown.

If the index is not set yet in that array, or if the array is not yet set, you are going to get an error message, which is indeed what is happening.