PHP_SELF

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kkurkowski
Forum Commoner
Posts: 53
Joined: Mon Dec 09, 2002 4:44 pm
Location: Michigan

PHP_SELF

Post 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?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

depends on how you determine the missing login and force the user to do so.
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post 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.
User avatar
nathus
Forum Commoner
Posts: 49
Joined: Thu Dec 12, 2002 6:23 pm

Post 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");
Post Reply