SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict
    Join Date
    Nov 2004
    Location
    New Jersey
    Posts
    317
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Storing form data and passing via POST?

    I'd like to take the data entered into a form and store it in a MySQL table using PHP, then pass to a target page using POST.

    For instance say the standard version of the form would pass to the target.html page:
    HTML Code:
    <form name="input" action="target.html" method="POST">
    First name: <input type="text" name="fname" /><br />
    Last name: <input type="text" name="lname" /><br />
    Phone: <input type="text" name="lname" /><br />
    <input type="submit" value="Submit" />
    </form>
    What approaches could one take to accomplish the storing of the form data into MySQL, and then passing the data via POST to the target page?

  2. #2
    SitePoint Enthusiast
    Join Date
    Jul 2006
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You cannot submit a form to one page and access the POST data on another You would need to submit the form to your target page and do the database insert from that page.

    The other option is to submit to the same page that the form is located on, insert the data into the database, set up a session and redirect the user to the target page.

  3. #3
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    72 Post(s)
    Tagged
    0 Thread(s)
    Not... entirely true.

    You can have the form on page A (local) be processed by page B (local); during page B's execution, it can cURL the data out to page C (remote).

    It wont fool the URL bar, but the data will get passed.
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.

  4. #4
    SitePoint Enthusiast
    Join Date
    Jul 2006
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sure, you could cURL the data to page C but is that really necessary when you can just submit the form to page C and handle everything from that page? Seems like an unnecessary step to me.

  5. #5
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    72 Post(s)
    Tagged
    0 Thread(s)
    Depends on if you're in control of Page C or not.
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.


Tags for this Thread

Bookmarks

Posting Permissions

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