note 59350 added to reserved.variables

From: Date: Sun, 04 Dec 2005 06:32:17 +0000
Subject: note 59350 added to reserved.variables
Groups: php.notes 
Request: Send a blank email to php-notes+get-99541@lists.php.net to get a copy of this message
Earlier this was posted: ------------------ To display the url of a page (like the one in the address bar) you can use this script: <?php echo "http://"; echo $_SERVER['HTTP_HOST']; //outputs sitename.com etc echo $_SERVER['REQUEST_URI']; //outputs /index.php etc ?> This could be used in a login script to redirect the user back to the page they logged in from instead of the index ------------------ In reality to use this to redirect back, you have to send this information along with the posted information as a hidden variable, in which case you could also referrence the $_SERVER['PHP_SELF'] as the action of the login form (provided the handling code was in the same file or included/required in the same file) and it will carry out the login function and stay on the same page. The comment of using it as a redirect is misleading, as $_SERVER['REQUEST_URI'] will, when used on the login page, only show /login.php, not /index.php or /whereyoucamefrom.php. Which is okay, if you have a login form on each page and not a dedicated login page to handle this procedure. In my case, you could be on pageone.php and click the login link which takes you to login.php, then the value of the variable is /login.php not the page you were on as the value is of the current page, not the referring page. ---- Manual Page -- http://www.php.net/manual/en/reserved.variables.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+59350 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+59350&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+59350&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+59350&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+59350&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+59350&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+59350&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+59350&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+59350&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#99541) next »