PHP Curl Help

Discussion in 'PHP' started by blake3334, Feb 29, 2012.

  1. #1
    I am using PHP curl to submit form post data to a external form on a different site, the problem is the form itself then posts to another form post data that I can't possiblely make up my self it sends the usually information but sends a savesql of the previous data, now is it possible to break down the savesql and send my save sql to the form?
     
    blake3334, Feb 29, 2012 IP
  2. trendint

    trendint Peon

    Messages:
    52
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You shouldn't be posting to the external form, but to the end location of the external form;

    I.E. check the <form> tag on the external page, get the location it is posting to and make sure that the fields you are posting to are all named correctly with the form elements on that page;

    You can also "automate" remote forms though using the Perl WWW::Mechanize implementation for PHP - I haven't used it, only the original Perl library but if it's an accurate clone it would be suitable for your needs. It's available at http://www.compasswebpublisher.com/php/www-mechanize-for-php
     
    trendint, Feb 29, 2012 IP
  3. blake3334

    blake3334 Member

    Messages:
    407
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    26
    #3
    The problem is you can't post to the end location since it gets post data from the first post form that you can't get with out posting to the first. Get it? The 2nd post sends a input named savesql and it's in some encrypted format.
     
    blake3334, Feb 29, 2012 IP
  4. trendint

    trendint Peon

    Messages:
    52
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Right - so in that case you want to grab that information and pass it on to the second post - to a certain extent it's a form of screen scraping. Using the Mechanize library is ideal for that kind of work. It basically will allow you to make requests as if you are a webbrowser and you can automate the actions - so it would make the first post, gather the information you are looking for, and the you can continue on the next form. I've done this tons of times in the past with the Perl library and the PHP one looks very similar in functionality.
     
    trendint, Feb 29, 2012 IP
  5. trendint

    trendint Peon

    Messages:
    52
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    trendint, Feb 29, 2012 IP
  6. blake3334

    blake3334 Member

    Messages:
    407
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    26
    #6
    Well I need PHP Curl help not mech.
     
    blake3334, Mar 1, 2012 IP
  7. TimeForCode

    TimeForCode Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    In cases like this, this is what I do...

    I use my trusty Firebug, and modify the action="xxxx.xxx" to point to a path on my server that just echoes out the variables for me. Then I get to see what's happening and whats being posted. If it's a double form (so to speak) then do the same thing on the second form and post it to a script to see it echo out the variables. Then from there you WILL know what's being posted back and can work with it from there.
     
    TimeForCode, Mar 2, 2012 IP