POST form to 2 places

Discussion in 'PHP' started by moosinator, May 13, 2008.

  1. #1
    I am working on a website and I have a form that asks for a few inputs from users and I would like to save the fields to my local SQL database and still POST them to an external website.

    This is how i have the form tag set up right now:
    <form name="example_form" method="POST" action="http://www.example.com/dir/result.php">

    I would like it to Save the fields to my SQL database before it POSTs them to the above website.

    Please help me if you can!!!
    Thank you.
     
    moosinator, May 13, 2008 IP
  2. tomazinis

    tomazinis Peon

    Messages:
    30
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Step 1 - post data to your script and wrtite to DB.
    Step 2 - send data to other website using CURL.
     
    tomazinis, May 14, 2008 IP
  3. tomazinis

    tomazinis Peon

    Messages:
    30
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You can use AJAX for solving this problem.
     
    tomazinis, May 14, 2008 IP
  4. msaqibansari

    msaqibansari Peon

    Messages:
    84
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    use onsubmit event in <form> by using you post all data to specific url using ajax/iframe and then normally post form data
     
    msaqibansari, May 14, 2008 IP
  5. AsHinE

    AsHinE Well-Known Member

    Messages:
    240
    Likes Received:
    8
    Best Answers:
    1
    Trophy Points:
    138
    #5
    As far as I know you can't normally access other domain using AJAX, so you submit your form to your script (on the same domain as form located) with AJAX and place other script in action of this form.
     
    AsHinE, May 14, 2008 IP
  6. moosinator

    moosinator Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I would like to accomplish this with out AJAX if possible because I don't want it to only work if someone has javascript enabled.

    I am new to PHP and am unfamiliar with cURL. If I use this method will it still transfer the user to the external page?


    Thank you for your input.
     
    moosinator, May 14, 2008 IP
  7. tomazinis

    tomazinis Peon

    Messages:
    30
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7

    No CURL not transfer user to another page, but you can transer user to externel page using header function, after you write data to DB -
    header("Location:http://www.your-another-page.com")
     
    tomazinis, May 14, 2008 IP
  8. moosinator

    moosinator Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    if i use the header function will i still be able to POST the form's fields to the external website with the same results as if i just POSTed it right to the website without it knowing any differant?
     
    moosinator, May 14, 2008 IP
  9. Student Gamers

    Student Gamers Banned

    Messages:
    47
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Could save the files to the database and then use a seperate page to load the database information to an RSS feed. The other website sources upon this RSS feed. Wouldn't even really have to be an RSS feed, could just write the data to the page then use "file_get_contents()" to read on your external site. If the external site is located on the same hosting page it could also share the database.
     
    Student Gamers, May 14, 2008 IP
  10. moosinator

    moosinator Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    I dont have access to the external website... I can't change the way they receive the information at all or it wont work. I have never done anything with rss feeds and am not sure how to do that. I know this is sounding increasingly harder... I wish there was just a way to POST a form to 2 places at the same time.
     
    moosinator, May 14, 2008 IP