Page 1 of 1

PHP_SELF

Posted: Sun Dec 15, 2002 5:59 pm
by kkurkowski
Do you know the command that gets the website that you are already at. Say on my site I have the login on every page and when they login it automatically goes to the news.php page. Does anyone know the command so that it goes back to the page that they were at when they are logged in?

Posted: Sun Dec 15, 2002 8:23 pm
by volka
depends on how you determine the missing login and force the user to do so.

Posted: Sun Dec 15, 2002 10:04 pm
by hob_goblin
you will definantly need to store this information somewhere such as a mysql table for later use. there is no way you can just figure out without sotring it.

Posted: Sun Dec 15, 2002 11:01 pm
by nathus
if you want users to return to the page they logged in from you could have your form something like this.

**edit** for some reason the <? echo $PHP_SELF ? > isn't showing the ?>

Code: Select all

<form method="post" action="login.php?page=<? echo $PHP_SELF  ?>">
<input type="text" name="name">
<input type="password" name="pass">
<input type="submit" value="login">
</form>
then in your login page have something like this

Code: Select all

$page = $_GET['page'];
your validation script here, if valid do this
Header("Location: $page");