Every example I've seen of form processing uses something like

<FORM ACTION="xx.php" METHOD="Post">

I don't mind doing it that way, but I want to perhaps have tidier code and one of my ways of doing this would be for a form action to, instead of loading a new php file and that doing the validation, make the form process a function

Is this possible?

I was trying some things out (bearing in mind I am new and have tried to search these forums for my answer) and had some code that looked like

<FORM ACTION="<?php 'function test()' ?>" METHOD="Post">

It wasn't doing anything so I guess I am doing something wrong and hoped someone might have some examples of where they have got this to work (or tell me I am being stupid and it's not possible 🙂 )

    I don't think it's possible. The action is a page that the form expects to be redirected to.

    If you don't like lots of pages you can always redirect to yourself ($PHP_SELF) and handle the call that way.

      How would I interpret that

      if ( action == submitted)
      {
      etc etc

      I can see what you are saying, doing it the $PHP_SELF way but I am unclear

        I usualy add a hidden input field so that my script knows that it's the target of a form.

          Give each submit button a unique name.

            A sample of $PHP_SELF will be something like this

            filename: sample.php

            content:

            <?php

            if ($submit):

            {do some php functions to process the form}

            else:
            ?>

            <FORM ACTION="<?php echo($PHP_SELF); ?>" METHOD=POST>
            Username: <INPUT TYPE=TEXT NAME="username"><BR>
            Password: <INPUT TYPE=PASSWORD NAME="password"><BR>
            <INPUT TYPE=SUBMIT NAME="submit" VALUE="SUBMIT">
            </FORM>

            <?php endif; ?>

            Hope this helps

            Laura Brandt


            Aletia Hosting - Full-Featured, Superfast Web Hosting
            PHP, MySQL, Perl, Multiple domain support and more.
            200MB + 10GB Transfer at $9.95/mth
            http://AletiaHosting.com

              Now I see where your coming from, thanks all!

                Write a Reply...