Hi, can a html form's action attribute call some php code in the same page it is on?

Something like this...

<?php
maybe some php code that always runs goes here.
.
.
.

IF form action== submitted

do this
.
.
.
END IF
?>

<html>
<form>
.
.
.
</html>

Is this possible? Hope this makes sense.

Thanks!

ben

    this is usually done like this:

    <?PHP
      if ($_POST['submitted'])
      {
        // form has been submitted
      }
      else
      {
    ?>
    <html>
    ...
    <form method=post action="<?PHP echo $_SERVER['PHP_SELF']; ?>">
    ...
    <input type=hidden name=submitted value=1>
    ...
    </form>
    ...
    </html>
    <?PHP
      }
      // anything
    
    ?>

      Thank you very much. This does what I need to do!

      ben

        Write a Reply...