The Apache Haus Forum

Forum Topics => Scripting Languages => Topic started by: mario on March 31, 2009, 08:09:45 PM

Title: PHP Get urls params for bookmarked pages
Post by: mario on March 31, 2009, 08:09:45 PM
Often users make bookmarks on page with GET params which are only availibe when you are logged in. Senario: Call bookmark, but you are redirected to the login and than to the start page but not to the bookmark. So we take the url params and save them and after login go back to the requested page.

Code: [Select]
* @return string $self Komplette URL mit allen Parametern
function get_this_uri_and_params(){
$self = $_SERVER['PHP_SELF'];
$n = 0;
foreach($_GET as $name=>$val){
$self .= "?";
$self .= "&";
//& ??
$self .= $name."=".$val;
return $self;

$self = $this->get_this_uri_and_params();
echo <<<END
<form action="$self" method="post" name="login">
<tr><td>Loginname:</td><td><input type="text" name="suser" /></td></tr>
<tr><td>Passwort:</td><td><input type="password" name="spass" /></td></tr>
<tr><td><input type="submit" value="Login" /></td><td>&nbsp;</td></tr>

Hope this short snippet helps someone