anatak Posted January 18, 2007 Share Posted January 18, 2007 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 Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 18, 2007 Share Posted January 18, 2007 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. Quote Link to comment Share on other sites More sharing options...
anatak Posted January 18, 2007 Author Share Posted January 18, 2007 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.thanksanatak Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 18, 2007 Share Posted January 18, 2007 you can use $_SERVER['REQUEST_URI'];If it's on a topic, and your structure is like /topics.php?id=1then you'd just save $_SESSION['topic'] = 1;and then redirect to your page. You don't need to know the whole URL, you should "know" it already. Quote Link to comment Share on other sites More sharing options...
anatak Posted January 18, 2007 Author Share Posted January 18, 2007 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=1some other pages are like index.php?p=10&a=10I was looking for a function that gets the full url of a pageanatak Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 18, 2007 Share Posted January 18, 2007 [quote author=jesirose link=topic=122930.msg507619#msg507619 date=1169099015]you can use $_SERVER['REQUEST_URI'];[/quote] Quote Link to comment Share on other sites More sharing options...
anatak Posted January 18, 2007 Author Share Posted January 18, 2007 Hey jesirose,thank you that is what I needed. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.