PHP - How to recall 'this' PHP script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • beanmg
    New Member
    • Jan 2007
    • 1

    PHP - How to recall 'this' PHP script

    I am writing a PHP script generating a number of HTML form-based actions that recalls the same script with different parameters - this works fine as I can name 'this' script in the HTML form's action parameter.

    However there is an occasion that I (re)call the script with parameters that cause an action to take place. When this is complete no further user input is required before I want to run the script again with no parameters to carry out the first-time-through actions again.

    I understand that $_SERVER['PHP_SELF'] contains the name of 'this' script but I do not know how to get PHP to call it. I imagine that I also need to stop the current execution of 'this' script with an exit()

    Can anyone help, please.

    Beano
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    There are several ways to call 'this' script.

    1. form in HTML code:
    in HTML code: [php]<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">[/php]
    2. forum generated in PHP code:
    [php]echo '<form action="$_SERVE R['PHP_SELF']" method="POST">'[/php]
    3. 'independent' call: [php]header("Locatio n: ".$_SERVER['PHP_SELF']);[/php]
    It is always sensible to terminate the script with an 'exit;' statement.

    Ronald :cool:

    Comment

    Working...