Results 1 to 29 of 29

Thread: submitting a form in PHP?

  1. #1

    Thread Starter
    Hyperactive Member Dodger's Avatar
    Join Date
    Mar 2001
    Posts
    433

    Question submitting a form in PHP?

    Can it be done?

    TIA.

  2. #2
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Yes...

    Set your form up: <form action="page.php" method="post">

    and get the form stuff like:

    Code:
    echo $_REQUEST['field_name'];
    Or just do a search of these forums or read the manual: http://www.php.net/

    submitting/reading forms is rather elementary.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  3. #3
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337

    Re: submitting a form in PHP?

    Originally posted by Dodger
    Can it be done?

    TIA.
    NO, if you do it you will be the 1st EVER to do it in php. you better write a book

  4. #4
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Sorry, I was in a bit of a hurry before.

    Here's something basic:

    Code:
    //let's call this bung.php
    
    if (isset($_REQUEST['submit'])) {
        //the form was sent:
        echo "What's up, " . $_REQUEST['name'] . "?!";
    } else {
        echo '<form action="bung.php" method="post">
            <input type="text" name="name"><br>
            <input type="submit" value=" Submit ">
        </form>';
    }
    Basically all there is to it.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  5. #5

    Thread Starter
    Hyperactive Member Dodger's Avatar
    Join Date
    Mar 2001
    Posts
    433
    The Hobo,

    You saying the form will be automatically submitted just by echoing it?

  6. #6
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    no, to submit it you have to push on the submit button.

    just like a html form no different

  7. #7

    Thread Starter
    Hyperactive Member Dodger's Avatar
    Join Date
    Mar 2001
    Posts
    433
    I found a script at PSC that can do it through code.

  8. #8
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    and how is that? you have to click on something. what would the purpose to submitting the form is if the user doesn't get a chance to insert the info?

  9. #9
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by Dodger
    The Hobo,

    You saying the form will be automatically submitted just by echoing it?
    What phpman said. After you submit the form, the values that were in that form are stored in what is referred to as "super globals." Like $_REQUEST, $_POST, and $_GET, depending on how you setup the form. $_REQUEST holds both $_POST and $_GET variables, and a few others.

    So once you submit the form, you have to check in your php file to see if it was submitted, and act accordingly. If the form has been submitted, these global variables are available for use in the php program for that time.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  10. #10
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by Dodger
    I found a script at PSC that can do it through code.
    What I showed you is doing it through code. Do you not see the code?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  11. #11
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by phpman
    and how is that? you have to click on something. what would the purpose to submitting the form is if the user doesn't get a chance to insert the info?
    My best bet is that he found some JavaScript code and is confusing it with PHP...
    My evil laugh has a squeak in it.

    kristopherwilson.com

  12. #12

    Thread Starter
    Hyperactive Member Dodger's Avatar
    Join Date
    Mar 2001
    Posts
    433
    Hey, don't be rude...lol

    I'm new to PHP...not that new!

    The script I found takes the URL and an associative array containing the input values, opens a socket connection and posts a request to the server.

  13. #13
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    ok see, they have to push submit to get the input values to go anywhere.

    what you are doing is the long way around and harder.

  14. #14
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by Dodger
    Hey, don't be rude...lol

    I'm new to PHP...not that new!

    The script I found takes the URL and an associative array containing the input values, opens a socket connection and posts a request to the server.
    ...

    What does this have to do with submitting a form?

    "opens a socket connection and posts a request to the server"

    Did you, by chance when you posted this thread, ask the wrong question or neglect to elaborate on your question?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  15. #15

    Thread Starter
    Hyperactive Member Dodger's Avatar
    Join Date
    Mar 2001
    Posts
    433
    The Hobo,

    No I didn't, I was asking for code to simulate a form submission.

    D.

  16. #16
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by Dodger
    The Hobo,

    No I didn't, I was asking for code to simulate a form submission.

    D.
    You asked if it was possible to submit a form in PHP.

    Yes. Hit the submit button...
    My evil laugh has a squeak in it.

    kristopherwilson.com

  17. #17

    Thread Starter
    Hyperactive Member Dodger's Avatar
    Join Date
    Mar 2001
    Posts
    433
    *sigh*

    I have a 'quick register' form at my site, I am simply looping through a member database and submitting the form for each member.

    D.

  18. #18
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by Dodger
    *sigh*

    I have a 'quick register' form at my site, I am simply looping through a member database and submitting the form for each member.

    D.
    That makes no sense...

    Why don't you just do it in code? Are you creating a form, putting the values in the fields, and simulating a submit?

    Again, that makes no sense.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  19. #19
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    you didn't say anything about a simulation?

  20. #20

    Thread Starter
    Hyperactive Member Dodger's Avatar
    Join Date
    Mar 2001
    Posts
    433
    The registration script is not made by myself, it has various functions, it's not a simple sql insert. It's possible to include the registration page and call the register function, but I think the script expects values in the $_POST variables.

  21. #21
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    well yeah, you could have teh form submtted by the user and then in the php check script you can send variabels to the function

    so the scruipt that simulates a submit, does it expects a return answer, becasue that is pretty much what teh socket connection is doing.

    still don't make any sense to what you are doing.

  22. #22

    Thread Starter
    Hyperactive Member Dodger's Avatar
    Join Date
    Mar 2001
    Posts
    433
    yes the script does ask for ther result of the request.

  23. #23
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    so how are you sending the form info?

  24. #24
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    I'm just not understanding what he's doing and why he's doing it, so I'll leave this thread up to you, phpman.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  25. #25
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    me?? I don't understand either

  26. #26

    Thread Starter
    Hyperactive Member Dodger's Avatar
    Join Date
    Mar 2001
    Posts
    433
    lol, don't worry guys, I'll try some other way.

    Thanks.

  27. #27
    New Member
    Join Date
    Sep 2002
    Location
    The World of Xeen
    Posts
    14
    I think I know what you're trying to do. Correct me if I'm wrong..

    You have a database with users or something like that in there. You want to submit the data from each of these records to another form. To do this you want to "fake" the submission of a form (ie open a web page and supply the form values without requiring a form to be displayed and clicking on the submit button)

    Am I right??

    I know how to do this in Visual Basic - you can use the WebBrowser control to open a page and specify optional headers (Eg the form values in the POST header.) As for doing it in PHP..? I have no idea.

    Why not just modify the script to read the entries from the database and process them one by one within that same script. Would be easier in the long run I think.

    Matt

  28. #28
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    if you understood that then you get the booby prize LOL

    I still don't know what he wants.

  29. #29

    Thread Starter
    Hyperactive Member Dodger's Avatar
    Join Date
    Mar 2001
    Posts
    433
    That's it, Matt.

    I ended up adding the records to the db directly once I figured out which fields were required.

    Thx.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width