FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

php get current page name

 


the zephyrus
Let's say I want a form to direct to the current page, although I don't know what the page is named. How can I use php to print out the current page name into the action property?
sonam
You can get current page with $_SERVER['PHP_SELF'] function.

Code:
$current = $_SERVER['PHP_SELF'];



But in many cases I didn't use anything. Blank action will run script on current page.

Sonam
hexkid
Try this:

Code:
...
<!-- this is HTML, not PHP (yet) -->
<form method="post" action="http://<?php echo $_SERVER['HTTP_HOST'], $_SERVER['PHP_SELF']; ?>">
  <!-- other form elements -->
</form>
...
manum
dude try this


<?php
echo("<FORM ACTION = \"$_SERVER['PHP_SELF']\" method = \"POST\"");
?>
yjwong
In fact, you could leave the action property blank. The browser will automatically submit the form to the current page.
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.