By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,729 Members | 1,433 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,729 IT Pros & Developers. It's quick & easy.

Log In Page that goes back to REFERRING page

P: n/a
Hi,
I am using the following code to initialise a session, depending on
whether-or-not the users' log in attempt has been successful.

if ($session_ok == "TRUE") {
//open the session
session_start();
//assign user details to session
$_SESSION[txt_user] = $user_id;
$_SESSION[user_pass] = $user_pass;
$_SESSION[ses_state] = "TRUE";
header("Location: ../index.php");
}

as you can see the script then refers back to my index.php page, after the
session is ok'd.

What I would like to do is change this so that is goes back to the referring
page, instead of the index.php page, which requires the user to then
navigate to their previous page again.

I have attempted to use $HTTP_REFERER, although for me (on IE6) for some
reason their is no value in the variable!

Any help appreciated!

Thanks.

Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
jn
"Steve Macleod" <st********@leodhotmail.com> wrote in message
news:h4**************@news-binary.blueyonder.co.uk...
Hi,
I am using the following code to initialise a session, depending on
whether-or-not the users' log in attempt has been successful.

if ($session_ok == "TRUE") {
//open the session
session_start();
//assign user details to session
$_SESSION[txt_user] = $user_id;
$_SESSION[user_pass] = $user_pass;
$_SESSION[ses_state] = "TRUE";
header("Location: ../index.php");
}

as you can see the script then refers back to my index.php page, after the
session is ok'd.

What I would like to do is change this so that is goes back to the referring page, instead of the index.php page, which requires the user to then
navigate to their previous page again.

I have attempted to use $HTTP_REFERER, although for me (on IE6) for some
reason their is no value in the variable!

Any help appreciated!

Thanks.


Did you try $_SERVER['HTTP_REFERER']?
Jul 17 '05 #2

P: n/a
duh

thats working ok now

many thanks!
"jn" <us********************************@jasonnorris.ne t> wrote in message
news:32*********************@twister.tampabay.rr.c om...
"Steve Macleod" <st********@leodhotmail.com> wrote in message
news:h4**************@news-binary.blueyonder.co.uk...
Hi,
I am using the following code to initialise a session, depending on
whether-or-not the users' log in attempt has been successful.

if ($session_ok == "TRUE") {
//open the session
session_start();
//assign user details to session
$_SESSION[txt_user] = $user_id;
$_SESSION[user_pass] = $user_pass;
$_SESSION[ses_state] = "TRUE";
header("Location: ../index.php");
}

as you can see the script then refers back to my index.php page, after the session is ok'd.

What I would like to do is change this so that is goes back to the

referring
page, instead of the index.php page, which requires the user to then
navigate to their previous page again.

I have attempted to use $HTTP_REFERER, although for me (on IE6) for some
reason their is no value in the variable!

Any help appreciated!

Thanks.


Did you try $_SERVER['HTTP_REFERER']?

Jul 17 '05 #3

P: n/a
"Steve Macleod" <st********@leodhotmail.com> wrote in message news:<h4**************@news-binary.blueyonder.co.uk>...
Hi,
I am using the following code to initialise a session, depending on
whether-or-not the users' log in attempt has been successful.

if ($session_ok == "TRUE") {
//open the session
session_start();
//assign user details to session
$_SESSION[txt_user] = $user_id;
$_SESSION[user_pass] = $user_pass;
$_SESSION[ses_state] = "TRUE";
header("Location: ../index.php");
}

as you can see the script then refers back to my index.php page, after the
session is ok'd.

What I would like to do is change this so that is goes back to the referring
page, instead of the index.php page, which requires the user to then
navigate to their previous page again.

I have attempted to use $HTTP_REFERER, although for me (on IE6) for some
reason their is no value in the variable!


Wrong idea. What if the referrer page is other than your site?

The correct idea is to track the current url of the page in cookie.
So, while logining just check if that cookie is set; if it is set then
redirect to that page.

--
http://www.sendmetoindia.com - Send Me to India!
Email: rrjanbiah-at-Y!com
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.