Re: [PHP] Re: Redirection Question (I spoke to soon)
> Finally, > > Thanks to all that tried to help, but I found part of the problem - sort > of. In the file that I am trying to redirect to I have a form with the > line: > > action="post" name="testing"> > > It appears this line was corrupt somehow. CR/LF in your files brought over from MSWindows? > After I rewrote the line from > scratch it solved the problem of my paths being screwed up - why - I > have no idea. Maybe it had some weird control characters or something > that was screwing things up. > > However, there is still a problem with the header function - it still > will not redirect. So did you check for things like CR/LF? -- Joel Rees, programmer, Kansai Systems Group Altech Corporation (Alpsgiken), Osaka, Japan http://www.alpsgiken.co.jp -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Redirection Question (I spoke to soon)
on 7/24/03 8:13 PM, Beauford.2005 at [EMAIL PROTECTED] wrote: > > action="post" name="testing"> > someone else already raised this issue and it doesn't look like you caught it: you have two actions in your form (the second should probably read method="post"), e.g., is your form even submitting to season-write.php? the other potential issue is that you mentioned your redirect function is within an external include file. since you moved the code from one server to another, make sure that the include file is in the correct path since the paths may be different on the new server. you could test by doing some debugging such as require("/path/to/include_file") or die("could not find include file"); brian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: Redirection Question (I spoke to soon)
Are you outputting BLANK LINES??? eg.. if you have blank lines after your last ?> (closing PHP tag) in ANY one of the require/include/script files, you're outputting something and this cannot be the case. eg. if in VI echo $someecho function dosomethig() { // whatever } ?> <- THIS blank line will be regarded as Output. Hence You can't redirect! ~ <-- These sort of tidle marks are vi's way of saying.. no blank line below this. ~ ~ ~ ~ ` Cheers, Mun Heng, Ow H/M Engineering Western Digital M'sia DID : 03-7870 5168 -Original Message- From: Beauford.2005 [mailto:[EMAIL PROTECTED] Sent: Friday, July 25, 2003 3:06 AM To: [EMAIL PROTECTED] Subject: RE: [PHP] Re: Redirection Question (I spoke to soon) Errors are on and I get nothing, it won't even direct if I hard code header("Location: www.microsoft.com"); -Original Message- From: Jason Wong [mailto:[EMAIL PROTECTED] Sent: July 23, 2003 12:48 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] Re: Redirection Question (I spoke to soon) On Thursday 24 July 2003 11:37, Beauford.2005 wrote: > I found one of my problems and also implemented your suggestions, and > still the same thing. It will not redirect. > > The problem I found is that $_SERVER['SERVER_NAME'] does not include > the port number. On my Win PC I am using port 800. So I changed this > line > to: > > $_SESSION['goto'] = "http://"; . $_SERVER['SERVER_NAME'] .":800" . > $_SERVER['REQUEST_URI']; > > If I take the output from that and put it into my browser is works > just fine, but it will not work in the script. [snip] > header("Location: " . $_SESSION['goto']); > > If I echo $_SESSION['goto'] right after session_start() it shows > exactly what it should be. So I am at a loss. Have you checked your error logs? You should always, ALWAYS have error reporting on full, and check for errors. It could be that you're getting an "headers already sent sent" error. Does it work if you have a single line script: header("Location: whatever_$_SESSION['goto']_is_supposed_to_be"); -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* But Officer, I stopped for the last one, and it was green! */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: Redirection Question (I spoke to soon)
Thanks Mike.. You've been a GREAT help.. Cheers, Mun Heng, Ow H/M Engineering Western Digital M'sia DID : 03-7870 5168 -Original Message- From: Ford, Mike [LSS] [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 23, 2003 7:01 PM To: Ow Mun Heng; PHP Subject: RE: [PHP] Re: Redirection Question (I spoke to soon) > -Original Message- > From: Ow Mun Heng [mailto:[EMAIL PROTECTED] > Sent: 23 July 2003 11:37 > > I'm confused.. > > > With $_SESSION, there is no need to use the session_register(), > session_unregister(), session_is_registered() functions. Session > variables are accessible like any other variables. > > > I'm using > > session_start(); > session_register('username'); > $_SESSION['username'] = $row['username']; > session_register('user_id'); > $_SESSION['user_id'] = $row['user_id']; > session_register('access_level'); > $_SESSION['access_level'] = $row['access_level']; > > and checking if user is authenticated using > > if ( session_is_registered('user_id') ) > { > return true; > } > else > { > return false; > } > > > Am I in error? (I'm trying to code using register_globals=off) Yes. If you use only the $_SESSION array to set/get the values of your session variables, you do not need (and, in some versions of PHP, MUST NOT use) session_register() or any of its friends. The proper coding for what you are doing above is: session_start(); $_SESSION['username'] = $row['username']; $_SESSION['user_id'] = $row['user_id']; $_SESSION['access_level'] = $row['access_level']; and if (isset($_SESSION['user_id']) ) { return true; } else { return false; } (or even just return isset($_SESSION['user_id']); ! ;) Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: Redirection Question (I spoke to soon)
Finally, Thanks to all that tried to help, but I found part of the problem - sort of. In the file that I am trying to redirect to I have a form with the line: It appears this line was corrupt somehow. After I rewrote the line from scratch it solved the problem of my paths being screwed up - why - I have no idea. Maybe it had some weird control characters or something that was screwing things up. However, there is still a problem with the header function - it still will not redirect. I got around this by using a small javascript I found which seems to do the trick. I'd still be curious as to why the header will not work, but at this point I'm ecstatic that it works at all. if(isset($_SESSION['goto'])) { ?> http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Redirection Question (I spoke to soon)
You need the "http://"; ie. "http://www.microsoft.com"; Beauford.2005 wrote: Errors are on and I get nothing, it won't even direct if I hard code header("Location: www.microsoft.com"); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: Redirection Question (I spoke to soon)
Errors are on and I get nothing, it won't even direct if I hard code header("Location: www.microsoft.com"); -Original Message- From: Jason Wong [mailto:[EMAIL PROTECTED] Sent: July 23, 2003 12:48 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] Re: Redirection Question (I spoke to soon) On Thursday 24 July 2003 11:37, Beauford.2005 wrote: > I found one of my problems and also implemented your suggestions, and > still the same thing. It will not redirect. > > The problem I found is that $_SERVER['SERVER_NAME'] does not include > the port number. On my Win PC I am using port 800. So I changed this > line > to: > > $_SESSION['goto'] = "http://"; . $_SERVER['SERVER_NAME'] .":800" . > $_SERVER['REQUEST_URI']; > > If I take the output from that and put it into my browser is works > just fine, but it will not work in the script. [snip] > header("Location: " . $_SESSION['goto']); > > If I echo $_SESSION['goto'] right after session_start() it shows > exactly what it should be. So I am at a loss. Have you checked your error logs? You should always, ALWAYS have error reporting on full, and check for errors. It could be that you're getting an "headers already sent sent" error. Does it work if you have a single line script: header("Location: whatever_$_SESSION['goto']_is_supposed_to_be"); -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* But Officer, I stopped for the last one, and it was green! */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Redirection Question (I spoke to soon)
On Thursday 24 July 2003 11:37, Beauford.2005 wrote: > I found one of my problems and also implemented your suggestions, and > still the same thing. It will not redirect. > > The problem I found is that $_SERVER['SERVER_NAME'] does not include the > port number. On my Win PC I am using port 800. So I changed this line > to: > > $_SESSION['goto'] = "http://"; . $_SERVER['SERVER_NAME'] .":800" . > $_SERVER['REQUEST_URI']; > > If I take the output from that and put it into my browser is works just > fine, but it will not work in the script. [snip] > header("Location: " . $_SESSION['goto']); > > If I echo $_SESSION['goto'] right after session_start() it shows exactly > what it should be. So I am at a loss. Have you checked your error logs? You should always, ALWAYS have error reporting on full, and check for errors. It could be that you're getting an "headers already sent sent" error. Does it work if you have a single line script: header("Location: whatever_$_SESSION['goto']_is_supposed_to_be"); -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* But Officer, I stopped for the last one, and it was green! */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Redirection Question (I spoke to soon)
* Thus wrote Ow Mun Heng ([EMAIL PROTECTED]): > Hi Curt, > > I'm confused.. I'll try to clear this up for you. I'm going to see if I can get the documentation on the web site fixed also. It is rather confusing. There appears to be two ways to do sessions: '--- Style 1 (discuraged use): '--- session_start(); // start the session session_register('var'); // register global $var as session var $var = $row['var']; // assign global $var a value // now the session will save the value // that is inside $var as long as its global // scoped // check to see if $var is registered with the session handler if ( session_is_registered('var') ) { // session is registered but doesn't gaurentee // that a value is inside of it. // so check to see if there is a value if (isset($var)) { // yes we have a value } else { // no value assigned } } else { // session variable $var is not registered so the // variable $var will not be saved in the session } session_unregister('var'); // Now var will not be saved in the // session '--- Style 2 (prefered method): '--- session_start();// start the session $_SESSION['var'] = $row['var']; // set the session value // any time you need to access this // value you need to reference it // through $_SESSION['var'] // check to see if session 'var' is in the session if(isset($_SESSION['var']) ) { // yes, so pull it out and do stuff $var = $_SESSION['var']; // do stuff... } else { // no, there is no $_SESSION['var'] // and will not be saved in session. } unset($SESSION['var']); // Now var will not be saved in the // session HTH, Curt -- "I used to think I was indecisive, but now I'm not so sure." -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: Redirection Question (I spoke to soon)
> -Original Message- > From: Ow Mun Heng [mailto:[EMAIL PROTECTED] > Sent: 23 July 2003 11:37 > > I'm confused.. > > > With $_SESSION, there is no need to use the session_register(), > session_unregister(), session_is_registered() functions. Session > variables are accessible like any other variables. > > > I'm using > > session_start(); > session_register('username'); > $_SESSION['username'] = $row['username']; > session_register('user_id'); > $_SESSION['user_id'] = $row['user_id']; > session_register('access_level'); > $_SESSION['access_level'] = $row['access_level']; > > and checking if user is authenticated using > > if ( session_is_registered('user_id') ) > { > return true; > } > else > { > return false; > } > > > Am I in error? (I'm trying to code using register_globals=off) Yes. If you use only the $_SESSION array to set/get the values of your session variables, you do not need (and, in some versions of PHP, MUST NOT use) session_register() or any of its friends. The proper coding for what you are doing above is: session_start(); $_SESSION['username'] = $row['username']; $_SESSION['user_id'] = $row['user_id']; $_SESSION['access_level'] = $row['access_level']; and if (isset($_SESSION['user_id']) ) { return true; } else { return false; } (or even just return isset($_SESSION['user_id']); ! ;) Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: Redirection Question (I spoke to soon)
Hi Curt, I'm confused.. With $_SESSION, there is no need to use the session_register(), session_unregister(), session_is_registered() functions. Session variables are accessible like any other variables. I'm using session_start(); session_register('username'); $_SESSION['username'] = $row['username']; session_register('user_id'); $_SESSION['user_id'] = $row['user_id']; session_register('access_level'); $_SESSION['access_level'] = $row['access_level']; and checking if user is authenticated using if ( session_is_registered('user_id') ) { return true; } else { return false; } Am I in error? (I'm trying to code using register_globals=off) Cheers, Mun Heng, Ow H/M Engineering Western Digital M'sia DID : 03-7870 5168 -Original Message- From: Curt Zirzow [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 23, 2003 12:20 PM To: PHP Subject: Re: [PHP] Re: Redirection Question (I spoke to soon) * Thus wrote Beauford.2005 ([EMAIL PROTECTED]): > Sorry all, apparently this doesn't work on either Windows or Linux. > Again, I thought it was working and once I got farther along I see that > it really wasn't. Basically what I get after I login is an empty screen. > Here is what I have : > > This is the script that runs to see if the user is logged in. > > session_start(); > if(!$_SESSION['logged']) { > > session_register('goto'); > $_SESSION['goto'] = "http://"; . $_SERVER['SERVER_NAME'] . > $_SERVER['REQUEST_URI']; > > $url = "http://www.mysite.org/login/login.php";; > header("Location: $url"); > } > > The above works and redirects me to the login page and has the right > referring page as shown below. > > goto|s:59:"http://www.mysite.org/setup/inputs.php";; > > This is in my login.php script. After I verify the user login is > correct, this piece of code is executed. > > session_start(); > session_register('logged'); > session_register('user'); You don't need those two lines, they are only needed if ini.register_globals is on and you want the variables $logged and $user to automatically be sessioned as: $_SESSION['logged'] $_SESSION['user'] With $_SESSION, there is no need to use the session_register(), session_unregister(), session_is_registered() functions. Session variables are accessible like any other variables. I think this is were your problem is. Also what php version? If you are using $_SESSION and disable register_globals, do not use session_register(), session_is_registered() and session_unregister(), if your scripts shall work in PHP 4.2 and earlier. You can use these functions in 4.3 and later. Hmm.. After looking at the session_* documentation there are CAUTIONS all over the place.. The all seem to say dont use sesion_register, unregister, and is_registered when your using $_SESSION; > > $_SESSION['logged'] = "True"; > $_SESSION['user'] = $row['user']; > > $target = "Location: " . $_SESSION['goto']; > > session_unregister('goto'); Use: unset($_SESSION['goto']); > > header($target); what does echo($target) yeild? > > What I get after this is a blank page. The user has been logged in and > shows in the session file, but it just isn't redirecting. > HTH, Curt -- "I used to think I was indecisive, but now I'm not so sure." -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Redirection Question (I spoke to soon)
* Thus wrote Beauford.2005 ([EMAIL PROTECTED]): > Sorry all, apparently this doesn't work on either Windows or Linux. > Again, I thought it was working and once I got farther along I see that > it really wasn't. Basically what I get after I login is an empty screen. > Here is what I have : > > This is the script that runs to see if the user is logged in. > > session_start(); > if(!$_SESSION['logged']) { > > session_register('goto'); > $_SESSION['goto'] = "http://"; . $_SERVER['SERVER_NAME'] . > $_SERVER['REQUEST_URI']; > > $url = "http://www.mysite.org/login/login.php";; > header("Location: $url"); > } > > The above works and redirects me to the login page and has the right > referring page as shown below. > > goto|s:59:"http://www.mysite.org/setup/inputs.php";; > > This is in my login.php script. After I verify the user login is > correct, this piece of code is executed. > > session_start(); > session_register('logged'); > session_register('user'); You don't need those two lines, they are only needed if ini.register_globals is on and you want the variables $logged and $user to automatically be sessioned as: $_SESSION['logged'] $_SESSION['user'] With $_SESSION, there is no need to use the session_register(), session_unregister(), session_is_registered() functions. Session variables are accessible like any other variables. I think this is were your problem is. Also what php version? If you are using $_SESSION and disable register_globals, do not use session_register(), session_is_registered() and session_unregister(), if your scripts shall work in PHP 4.2 and earlier. You can use these functions in 4.3 and later. Hmm.. After looking at the session_* documentation there are CAUTIONS all over the place.. The all seem to say dont use sesion_register, unregister, and is_registered when your using $_SESSION; > > $_SESSION['logged'] = "True"; > $_SESSION['user'] = $row['user']; > > $target = "Location: " . $_SESSION['goto']; > > session_unregister('goto'); Use: unset($_SESSION['goto']); > > header($target); what does echo($target) yeild? > > What I get after this is a blank page. The user has been logged in and > shows in the session file, but it just isn't redirecting. > HTH, Curt -- "I used to think I was indecisive, but now I'm not so sure." -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: Redirection Question (I spoke to soon)
Hi, I found one of my problems and also implemented your suggestions, and still the same thing. It will not redirect. The problem I found is that $_SERVER['SERVER_NAME'] does not include the port number. On my Win PC I am using port 800. So I changed this line to: $_SESSION['goto'] = "http://"; . $_SERVER['SERVER_NAME'] .":800" . $_SERVER['REQUEST_URI']; If I take the output from that and put it into my browser is works just fine, but it will not work in the script. This is the portion of the script in question now after I implemented your changes. session_start(); $_SESSION['logged'] = "True"; $_SESSION['user'] = $row['user']; header("Location: " . $_SESSION['goto']); If I echo $_SESSION['goto'] right after session_start() it shows exactly what it should be. So I am at a loss. Ideas?? -----Original Message----- From: Ray Hunter [mailto:[EMAIL PROTECTED] Sent: July 22, 2003 10:47 PM To: Beauford.2005 Subject: Re: [PHP] Re: Redirection Question (I spoke to soon) Try doing: session_start(); $_SESSION['logged'] = "True"; $_SESSION['user'] = $row['user']; // you cant do this here. // session_unregister('goto'); header( "Location: ".$_SESSION['goto'] ); That should work. -- BigDog On Wed, 2003-07-23 at 19:35, Beauford.2005 wrote: > Sorry all, apparently this doesn't work on either Windows or Linux. > Again, I thought it was working and once I got farther along I see > that it really wasn't. Basically what I get after I login is an empty > screen. Here is what I have : > > This is the script that runs to see if the user is logged in. > > session_start(); > if(!$_SESSION['logged']) { > > session_register('goto'); > $_SESSION['goto'] = "http://"; . $_SERVER['SERVER_NAME'] . > $_SERVER['REQUEST_URI']; > > $url = "http://www.mysite.org/login/login.php";; > header("Location: $url"); > } > > The above works and redirects me to the login page and has the right > referring page as shown below. > > goto|s:59:"http://www.mysite.org/setup/inputs.php";; > > This is in my login.php script. After I verify the user login is > correct, this piece of code is executed. > > session_start(); > session_register('logged'); > session_register('user'); > > $_SESSION['logged'] = "True"; > $_SESSION['user'] = $row['user']; > > $target = "Location: " . $_SESSION['goto']; > > session_unregister('goto'); > > header($target); > > What I get after this is a blank page. The user has been logged in and > shows in the session file, but it just isn't redirecting. > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Redirection Question (I spoke to soon)
Beauford.2005 wrote: Sorry all, apparently this doesn't work on either Windows or Linux. Again, I thought it was working and once I got farther along I see that it really wasn't. Basically what I get after I login is an empty screen. Here is what I have : This is the script that runs to see if the user is logged in. session_start(); if(!$_SESSION['logged']) { session_register('goto'); $_SESSION['goto'] = "http://"; . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; $url = "http://www.mysite.org/login/login.php";; header("Location: $url"); } The above works and redirects me to the login page and has the right referring page as shown below. goto|s:59:"http://www.mysite.org/setup/inputs.php";; This is in my login.php script. After I verify the user login is correct, this piece of code is executed. session_start(); session_register('logged'); session_register('user'); $_SESSION['logged'] = "True"; $_SESSION['user'] = $row['user']; $target = "Location: " . $_SESSION['goto']; session_unregister('goto'); header($target); What I get after this is a blank page. The user has been logged in and shows in the session file, but it just isn't redirecting. 1. DON'T mix session_register() and $_SESSION. 2. Add an exit(); after you redirect with header(). -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ PHP|Architect: A magazine for PHP Professionals – www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Redirection Question (I spoke to soon)
Sorry all, apparently this doesn't work on either Windows or Linux. Again, I thought it was working and once I got farther along I see that it really wasn't. Basically what I get after I login is an empty screen. Here is what I have : This is the script that runs to see if the user is logged in. session_start(); if(!$_SESSION['logged']) { session_register('goto'); $_SESSION['goto'] = "http://"; . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; $url = "http://www.mysite.org/login/login.php";; header("Location: $url"); } The above works and redirects me to the login page and has the right referring page as shown below. goto|s:59:"http://www.mysite.org/setup/inputs.php";; This is in my login.php script. After I verify the user login is correct, this piece of code is executed. session_start(); session_register('logged'); session_register('user'); $_SESSION['logged'] = "True"; $_SESSION['user'] = $row['user']; $target = "Location: " . $_SESSION['goto']; session_unregister('goto'); header($target); What I get after this is a blank page. The user has been logged in and shows in the session file, but it just isn't redirecting. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Redirection Question
"Beauford.2005" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > > I am trying to figure out how to redirect a user back to a page but not > having much luck. > > For example: I click on a menu item on my site which goes to a.php. This > file includes another file that determines if they are logged in or not. > If not, they are sent to login.php using header(:Location: ). How > would I automatically redirect them back to a.php after they have logged > in successfully. I have tried using HTTP_REFERRER, but it isn't > redirecting. > > Any help is appreciated. When you redirect to login.php store the refering page in a hidden form field field and redirect back to that url after the user has logged in succesfully. HTH, Kevin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php