note 68541 added to function.parse-url

From: Date: Tue, 01 Aug 2006 13:50:10 +0000
Subject: note 68541 added to function.parse-url
Groups: php.notes 
Request: Send a blank email to php-notes+get-115410@lists.php.net to get a copy of this message
For a login function on a separate page, it's useful to send the user back to the page where they came from (rather than just the home page or something) so the following function checks to see if the file actually exists on the system (and is a valid referrer). It would be better to put the referrer value into a hidden form on the page and then after post (and checking password etc) check for $_POST['referrer']. <?php function referrer() { $location = "location:index.php"; if (isset($_SERVER['HTTP_REFERER'])) { $referrer = parse_url($_SERVER['HTTP_REFERER']); $path = $referrer['path']; $query = $referrer['query']; $hardfile = str_replace($_SERVER['PHP_SELF'], "", __FILE__ . $path); if(is_file($hardfile)) { $location = "location:$path?$query"; } } header($location); } ?> ---- Server IP: 85.116.0.130 Probable Submitter: 148.197.60.140 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.parse-url.php Edit -- https://master.php.net/note/edit/68541 Del: integrated -- https://master.php.net/note/delete/68541/integrated Del: useless -- https://master.php.net/note/delete/68541/useless Del: bad code -- https://master.php.net/note/delete/68541/bad+code Del: spam -- https://master.php.net/note/delete/68541/spam Del: non-english -- https://master.php.net/note/delete/68541/non-english Del: in docs -- https://master.php.net/note/delete/68541/in+docs Del: other reasons-- https://master.php.net/note/delete/68541 Reject -- https://master.php.net/note/reject/68541 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#115410) next »