Page 1 of 1

Passing of variable using URL problem

Posted: Sat Sep 13, 2008 1:41 am
by 3hhh
Hi,

I have a problem with the passing of variables using URL. I have two pages. One is a login page and the other is an action page for the login. If the login fails, the action page will redirect the user back to the login page with a

$ref = $_SERVER['HTTP_REFERER'];
header("Location: ".$ref."?login=failed");

Thus, the above will redirect the user to http://www.somesite.com/login.php?login=failed

However, if the user fails the login process again, the page will redirect the user to http://www.somesite.com/login.php?[b]lo ... gin=failed[/b]
If he fails three times, the ?login=failed will be displayed THREE times and so on.

This is incorrect. I just want ?login=failed to be passed ONCE despite how many times the user fails his login authentication.

What have I done wrong in the code? Kindly advise pls. Thank you so much! :)

Re: Passing of variable using URL problem

Posted: Sat Sep 13, 2008 2:39 am
by Ziq
You can use a parse_url() function. You should check a $ref variable, because not always $_SERVER['HTTP_REFERER'] set(defined).

For example, execute this php-code:

Code: Select all

 
<?
 
$url='http://www.somesite.ru/page.php?login=123123&asdasd=213';
print_r(parse_url($url));
 
?>