call php funktion from form

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

    #1

    call php funktion from form

    hi!

    I don't have eny code to chare, this is just teoretical question.
    usualy you have for looks like
    <form method="POST" action="some_ph p_script.php">
    namn: <input type="text" name="name" size="20">
    <br>
    city <input type="text" name="city" size="20">
    <input type="submit" value="Submit"> <input type="reset">
    </form>

    what I am wondering how it would by possible to send name to one funktion
    in some_php_script .php and city to another?
    I mean if I have some_php_script .php
    <?
    name_funktion( $name ){
    code...
    code..
    }

    city_funktion( $city ){
    code...
    code..
    }
    ?>

    so I want to send parameter name from form to name_funktion() and city to
    city_funktion()


    --

    Thanx in advance
    _______________ _________
    BTW. I know my english is not best in the word, so please stop bugging me
    about my spelling. And yes Iam sorry you don't understand what I mean, but
    there is no point to yell at me. Have a nice day.

  • Alvaro G Vicario

    #2
    Re: call php funktion from form

    *** Carramba wrote/escribió (Wed, 15 Jun 2005 10:24:31 +0200):[color=blue]
    > so I want to send parameter name from form to name_funktion() and city to
    > city_funktion()[/color]

    You can read form fields from the $_POST associative array this way:

    <input name="foo" ... >

    echo $_POST['foo'];


    --
    -- Álvaro G. Vicario - Burgos, Spain
    -- http://bits.demogracia.com - Mi sitio sobre programación web
    -- Don't e-mail me your questions, post them to the group
    --

    Comment

    • Carramba

      #3
      Re: call php funktion from form

      but does it means that I can reffer in action to some_php_script .php,
      and the from it declaire $foo = $_POST['foo'] and after words call
      function foo_function( $foo ) or foo_function( $_POST['foo'] )?
      how would it work if functions are in different *.php scrips? if I include
      them it ll work fine, but to by more precises I'am asking if there is a
      way to call different function in different script pages?


      On Wed, 15 Jun 2005 10:51:54 +0200, Alvaro G Vicario
      <alvaro_QUITAR_ REMOVE@telecomp uteronline.com> wrote:
      [color=blue]
      > *** Carramba wrote/escribió (Wed, 15 Jun 2005 10:24:31 +0200):[color=green]
      >> so I want to send parameter name from form to name_funktion() and city
      >> to
      >> city_funktion()[/color]
      >
      > You can read form fields from the $_POST associative array this way:
      >
      > <input name="foo" ... >
      >
      > echo $_POST['foo'];
      >
      >[/color]



      --

      Thanx in advance
      _______________ _________
      BTW. I know my english is not best in the word, so please stop bugging me
      about my spelling. And yes Iam sorry you don't understand what I mean, but
      there is no point to yell at me. Have a nice day.

      Comment

      • Alvaro G Vicario

        #4
        Re: call php funktion from form

        *** Carramba wrote/escribió (Wed, 15 Jun 2005 11:20:57 +0200):[color=blue]
        > but does it means that I can reffer in action to some_php_script .php,
        > and the from it declaire $foo = $_POST['foo'] and after words call
        > function foo_function( $foo ) or foo_function( $_POST['foo'] )?[/color]

        I guess English is not your mother tongue :) Form fields are created using
        HTML. If you don't want to display the form you can make it of hidden type:

        <input type="hidden" name="foo" value="Whatever ">

        [color=blue]
        > how would it work if functions are in different *.php scrips?[/color]

        You must understand that PHP is server-side and browsers cannot execute PHP
        at all. They merely load URLs and that triggers whatever PHP code you have
        placed there.

        [color=blue]
        > if I include
        > them it ll work fine, but to by more precises I'am asking if there is a
        > way to call different function in different script pages?[/color]

        Sorry, I can't figure out what you need. You can call as many functions as
        you want, just type their names and end each line with a semicolon. But I
        suppose you already know that :-?


        --
        -- Álvaro G. Vicario - Burgos, Spain
        -- http://bits.demogracia.com - Mi sitio sobre programación web
        -- Don't e-mail me your questions, post them to the group
        --

        Comment

        • Carramba

          #5
          Re: call php funktion from form

          On Wed, 15 Jun 2005 11:25:28 +0200, Alvaro G Vicario
          <alvaro_QUITAR_ REMOVE@telecomp uteronline.com> wrote:
          [color=blue]
          > *** Carramba wrote/escribió (Wed, 15 Jun 2005 11:20:57 +0200):[color=green]
          >> but does it means that I can reffer in action to some_php_script .php,
          >> and the from it declaire $foo = $_POST['foo'] and after words call
          >> function foo_function( $foo ) or foo_function( $_POST['foo'] )?[/color]
          >
          > I guess English is not your mother tongue :) Form fields are created
          > using[/color]
          yes you are so right :-P
          [color=blue]
          > HTML. If you don't want to display the form you can make it of hidden
          > type:
          >
          > <input type="hidden" name="foo" value="Whatever ">
          >
          >[color=green]
          >> how would it work if functions are in different *.php scrips?[/color]
          >
          > You must understand that PHP is server-side and browsers cannot execute
          > PHP
          > at all. They merely load URLs and that triggers whatever PHP code you
          > have
          > placed there.[/color]

          I know that[color=blue]
          >[color=green]
          >> if I include
          >> them it ll work fine, but to by more precises I'am asking if there is a
          >> way to call different function in different script pages?[/color]
          >
          > Sorry, I can't figure out what you need. You can call as many functions
          > as
          > you want, just type their names and end each line with a semicolon. But I
          > suppose you already know that :-?[/color]

          suppose I have functions in diffrenst scripts, thouse funktins are used
          not only in forms,
          for ex I wan't to call check_email() wich is in form_check.php for e-mail
          feeld in form,
          then I want to imput name in database wich is dome with insert_db() in
          db_handling.php
          so my question: how can I call thouse funktions without including them in
          some_php_script .php (<form method="POST" action="some_ph p_script.php">)
          so I send them dicectly to those funktions in thouse script collections
          I wan't to do that becouse I think it woud by quicker script execution
          hoppe I make myself clear now..


          --

          Thanx in advance
          _______________ _________
          BTW. I know my english is not best in the word, so please stop bugging me
          about my spelling. And yes Iam sorry you don't understand what I mean, but
          there is no point to yell at me. Have a nice day.

          Comment

          • Jerry Stuckle

            #6
            Re: call php funktion from form

            Carramba wrote:[color=blue]
            > On Wed, 15 Jun 2005 11:25:28 +0200, Alvaro G Vicario
            > <alvaro_QUITAR_ REMOVE@telecomp uteronline.com> wrote:
            >[color=green]
            >> *** Carramba wrote/escribió (Wed, 15 Jun 2005 11:20:57 +0200):
            >>[color=darkred]
            >>> but does it means that I can reffer in action to some_php_script .php,
            >>> and the from it declaire $foo = $_POST['foo'] and after words call
            >>> function foo_function( $foo ) or foo_function( $_POST['foo'] )?[/color]
            >>
            >>
            >> I guess English is not your mother tongue :) Form fields are created
            >> using[/color]
            >
            > yes you are so right :-P
            >[color=green]
            >> HTML. If you don't want to display the form you can make it of hidden
            >> type:
            >>
            >> <input type="hidden" name="foo" value="Whatever ">
            >>
            >>[color=darkred]
            >>> how would it work if functions are in different *.php scrips?[/color]
            >>
            >>
            >> You must understand that PHP is server-side and browsers cannot
            >> execute PHP
            >> at all. They merely load URLs and that triggers whatever PHP code you
            >> have
            >> placed there.[/color]
            >
            >
            > I know that
            >[color=green]
            >>[color=darkred]
            >>> if I include
            >>> them it ll work fine, but to by more precises I'am asking if there is a
            >>> way to call different function in different script pages?[/color]
            >>
            >>
            >> Sorry, I can't figure out what you need. You can call as many
            >> functions as
            >> you want, just type their names and end each line with a semicolon. But I
            >> suppose you already know that :-?[/color]
            >
            >
            > suppose I have functions in diffrenst scripts, thouse funktins are used
            > not only in forms,
            > for ex I wan't to call check_email() wich is in form_check.php for
            > e-mail feeld in form,
            > then I want to imput name in database wich is dome with insert_db() in
            > db_handling.php
            > so my question: how can I call thouse funktions without including them
            > in some_php_script .php (<form method="POST" action="some_ph p_script.php">)
            > so I send them dicectly to those funktions in thouse script collections
            > I wan't to do that becouse I think it woud by quicker script execution
            > hoppe I make myself clear now..
            >
            >[/color]

            Carramba,

            If I understand you correctly, you want to call a function which is in a
            script other than the one currently running. To do this, you must
            include the second script.

            For instance, in script1.php you might have (on Apache):

            <?php
            require_once($_ SERVER['DOCUMENT_ROOT'] . '/include/script2.php');
            ...
            ?>

            All the functions in script2.php are now available to be called by
            script1.php. The $_SERVER['DOCUMENT_ROOT'] is required because PHP
            operates on the file system itself. It means you need to add the root
            path to the web server files yourself.

            Is this what you mean?

            --
            =============== ===
            Remove the "x" from my email address
            Jerry Stuckle
            JDS Computer Training Corp.
            jstucklex@attgl obal.net
            =============== ===

            Comment

            • Alvaro G Vicario

              #7
              Re: call php funktion from form

              *** Jerry Stuckle wrote/escribió (Wed, 15 Jun 2005 06:37:35 -0500):[color=blue]
              > require_once($_ SERVER['DOCUMENT_ROOT'] . '/include/script2.php');[/color]

              I was about to answer this. One more comment: it's a good idea to use a
              special extension to distinguish this sort of files. I normally use
              something like "functions.inc. php".


              --
              -- Álvaro G. Vicario - Burgos, Spain
              -- http://bits.demogracia.com - Mi sitio sobre programación web
              -- Don't e-mail me your questions, post them to the group
              --

              Comment

              • Carramba

                #8
                Re: call php funktion from form

                On Wed, 15 Jun 2005 12:50:30 +0200, Alvaro G Vicario
                <alvaro_QUITAR_ REMOVE@telecomp uteronline.com> wrote:
                [color=blue]
                > *** Jerry Stuckle wrote/escribió (Wed, 15 Jun 2005 06:37:35 -0500):[color=green]
                >> require_once($_ SERVER['DOCUMENT_ROOT'] . '/include/script2.php');[/color]
                >
                > I was about to answer this. One more comment: it's a good idea to use a
                > special extension to distinguish this sort of files. I normally use
                > something like "functions.inc. php".
                >
                >[/color]

                thank you bouth!
                I was looking for thouse answers.
                my past in java/haskell/c have left some deep wounds, so Iam having
                trouble thinking php :P


                --

                Thanx in advance
                _______________ _________
                BTW. I know my english is not best in the word, so please stop bugging me
                about my spelling. And yes Iam sorry you don't understand what I mean, but
                there is no point to yell at me. Have a nice day.

                Comment

                • Alvaro G Vicario

                  #9
                  Re: call php funktion from form

                  *** Carramba wrote/escribió (Wed, 15 Jun 2005 12:57:04 +0200):[color=blue]
                  > my past in java/haskell/c have left some deep wounds, so Iam having
                  > trouble thinking php :P[/color]

                  Java makes bad things to human brain.


                  --
                  -- Álvaro G. Vicario - Burgos, Spain
                  -- http://bits.demogracia.com - Mi sitio sobre programación web
                  -- Don't e-mail me your questions, post them to the group
                  --

                  Comment

                  • Carramba

                    #10
                    Re: call php funktion from form

                    On Wed, 15 Jun 2005 13:05:14 +0200, Alvaro G Vicario
                    <alvaro_QUITAR_ REMOVE@telecomp uteronline.com> wrote:
                    [color=blue]
                    > *** Carramba wrote/escribió (Wed, 15 Jun 2005 12:57:04 +0200):[color=green]
                    >> my past in java/haskell/c have left some deep wounds, so Iam having
                    >> trouble thinking php :P[/color]
                    >
                    > Java makes bad things to human brain.
                    >
                    >[/color]

                    lol


                    --

                    Thanx in advance
                    _______________ _________
                    BTW. I know my english is not best in the word, so please stop bugging me
                    about my spelling. And yes Iam sorry you don't understand what I mean, but
                    there is no point to yell at me. Have a nice day.

                    Comment

                    • Carramba

                      #11
                      Re: call php funktion from form

                      On Wed, 15 Jun 2005 13:05:14 +0200, Alvaro G Vicario
                      <alvaro_QUITAR_ REMOVE@telecomp uteronline.com> wrote:
                      [color=blue]
                      > *** Carramba wrote/escribió (Wed, 15 Jun 2005 12:57:04 +0200):[color=green]
                      >> my past in java/haskell/c have left some deep wounds, so Iam having
                      >> trouble thinking php :P[/color]
                      >
                      > Java makes bad things to human brain.
                      >
                      >[/color]

                      shame you website is non-english..

                      --

                      Thanx in advance
                      _______________ _________
                      BTW. I know my english is not best in the word, so please stop bugging me
                      about my spelling. And yes Iam sorry you don't understand what I mean, but
                      there is no point to yell at me. Have a nice day.

                      Comment

                      Working...