Jump to content

login redirect


anatak

Recommended Posts

How can you redirect the user to the same page when he logs in ?

I want to make a function that is similar to the login function on phpfreaks.

here you are looking at a topic and then decide to login. after logging in you are automatically redirected to the topic you where viewing.

How can you do this ?

Is the best way to let the login go to a "thank you for logging in page" and then redirecting to the page you where viewing ?
Or can you do this in one step ?

I guess $_SERVER[] will have to be used but I am not sure exactly wich one and how.

anatak
Link to comment
https://forums.phpfreaks.com/topic/34688-login-redirect/
Share on other sites

you could use a hidden input field on the login form. Is the login form displayed on every page? Just add the current page in the form.

Or, if they have to go to a seperate page to login, whenever a topic is being viewed set the topic in the session, then after logging in check if they have a topic in the session and redirect there.
Link to comment
https://forums.phpfreaks.com/topic/34688-login-redirect/#findComment-163491
Share on other sites

Jesirose,

do you know how to get the current page ?
that is my main problem.
the form is on my main page so I wanted to make the action point to the current page
<form method=POST action =<?php echo $_SERVER[PHP_SELF]; ?>
but that has some strange behaviour from time to time.

thanks
anatak
Link to comment
https://forums.phpfreaks.com/topic/34688-login-redirect/#findComment-163494
Share on other sites

it is not really about a topic in a forum.
I was just using this as a reference.
the problem is that some pages have more than one variable in the url like index.php?p=3&id=2&sel=4&r=1
some other pages are like index.php?p=10&a=10

I was looking for a function that gets the full url of a page

anatak
Link to comment
https://forums.phpfreaks.com/topic/34688-login-redirect/#findComment-163503
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.