FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free 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.
Related topics
How to create a dynamic PHP website.
PHP index page not displaying problem
PHP what is it actually?
How can i make that intro page?
Master Tutorial on SEO
My first PHP + mySQL page - Need feedback
is there any way to trigger a .php file without refreshing?
PHP Get script name?
AJAX tutorial [2nd part now updated]
storing current page address as php variable
Developing a Login System with PHP and MySQL
Php form.
PHP page turning problem
php gallery
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

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