Call function from <form>

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ricki Susic

    Call function from <form>

    Hi,
    Can anyone tell me if it is possible to call a function from a html form,
    where the function is included in the same file as the form.


    <html>
    <body>

    <form method="post" action="what do I write here to acces function test()">
    <input type="text" name="tekst">
    <input type="submit" value="send">
    </form>

    <?php
    function test(){
    echo $tekst;
    }
    ?>


    </body>
    </html>

    Regards Ricki


  • Eto Demerzel

    #2
    Re: Call function from &lt;form&gt;

    In article <3f73e270$0$972 59$edfadb0f@dre ad12.news.tele. dk>, Ricki
    Susic's output was...[color=blue]
    > Hi,
    > Can anyone tell me if it is possible to call a function from a html form,
    > where the function is included in the same file as the form.
    >[/color]
    The HTML form needs to be a part of a .php file - and so action should =
    "filename.p hp" or do something like

    <?PHP
    printf("<FORM action=\"$PHP_S ELF\" method=\"post\" >");
    ?>

    You can do something along the lines of

    if ($tekst) {
    Function_Whatev erGoesHere();
    }
    to determine if something has been sent to the script already, or if you
    should just be displaying the form.


    **_ IF you have register_global s turned OFF (Like I should have by now)-
    $tekst will be $HTTP_POST_VARS['tekst']
    instead.


    --
    CurrentlyRaving About:

    Comment

    • Yves Brault

      #3
      Re: Call function from &lt;form&gt;

      Or maybe you should use JavaScript at that point...


      "Eto Demerzel" <eto.demerzel@f ijivillage.com> wrote in message
      news:MPG.19ddf8 c38cee648898971 a@news-text.blueyonder .co.uk...[color=blue]
      > In article <3f73e270$0$972 59$edfadb0f@dre ad12.news.tele. dk>, Ricki
      > Susic's output was...[color=green]
      > > Hi,
      > > Can anyone tell me if it is possible to call a function from a html[/color][/color]
      form,[color=blue][color=green]
      > > where the function is included in the same file as the form.
      > >[/color]
      > The HTML form needs to be a part of a .php file - and so action should =
      > "filename.p hp" or do something like
      >
      > <?PHP
      > printf("<FORM action=\"$PHP_S ELF\" method=\"post\" >");
      > ?>
      >
      > You can do something along the lines of
      >
      > if ($tekst) {
      > Function_Whatev erGoesHere();
      > }
      > to determine if something has been sent to the script already, or if you
      > should just be displaying the form.
      >
      >
      > **_ IF you have register_global s turned OFF (Like I should have by now)-
      > $tekst will be $HTTP_POST_VARS['tekst']
      > instead.
      >
      >
      > --
      > CurrentlyRaving About:
      > www.badgerbadgerbadger.com[/color]


      Comment

      Working...