1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Let PHP Submit Forms And Grab Result Page

Discussion in 'PHP' started by T0PS3O, Jun 16, 2005.

  1. #1
    I need to grab data from a result page after submitting a tracking code into a form. But I don't have a clue how to do that.

    Suppose the form element name in question is like 'name="trackingcode"' and the action="handler.php".

    Simply doing handler.php?trackingcode=1234 doesn't work since it works with session id's.

    So I need code that actually submits the form instead of spoofing the end result artificially.
    SEMrush
    Can this be done? I know you can get php to log in somewhere and grab that data so I guess that's the same.

    Can anyone point me in the right directions please?
     
    T0PS3O, Jun 16, 2005 IP
    noppid likes this.
    SEMrush
  2. THT

    THT Peon

    Messages:
    686
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    is it a post or get form?
     
    THT, Jun 16, 2005 IP
  3. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,220
    Likes Received:
    778
    Best Answers:
    0
    Trophy Points:
    0
    #3
    POST. But I've solved it with Advanced HTTP Class.
     
    T0PS3O, Jun 16, 2005 IP
  4. THT

    THT Peon

    Messages:
    686
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #4
    it wasnt adsense was it?

    Ive got a function which emulates a HTTP POst but i cant get my adsense stats using it....
     
    THT, Jun 16, 2005 IP
  5. noppid

    noppid gunnin' for the quota

    Messages:
    4,246
    Likes Received:
    232
    Best Answers:
    0
    Trophy Points:
    135
    #5
    post forms use the hidden imput element to send vars.

    <input type="hidden" name="s" value="$session[sessionhash]" />
    <input type="hidden" name="gallery" value="$gallery" />
     
    noppid, Jun 16, 2005 IP
  6. THT

    THT Peon

    Messages:
    686
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #6
    yeah i posted all the variables - even hidden ones.

    They also use HTTP POST instead of HTTP GET which you can emulate with cURL
     
    THT, Jun 16, 2005 IP
  7. noppid

    noppid gunnin' for the quota

    Messages:
    4,246
    Likes Received:
    232
    Best Answers:
    0
    Trophy Points:
    135
    #7
    You can emulate all you want, if the recieving end wants post vars and they are specifically addressed in $_POST, I see no reason $_GET vars will be handled.

    Most apps are specific as to which method they fetch from that I've see.

    And another thing, if you are emulating a post form to do an auto submit, some apps aslo have referrer checks to disallow that.

    Just a guess.
     
    noppid, Jun 16, 2005 IP
  8. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,220
    Likes Received:
    778
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Referers can be set with this class. You can set the headers, user agent and all sorts.

    Nothing malicious I'm doing though.
     
    T0PS3O, Jun 16, 2005 IP
  9. noppid

    noppid gunnin' for the quota

    Messages:
    4,246
    Likes Received:
    232
    Best Answers:
    0
    Trophy Points:
    135
    #9

    Of course not, we trust ya! ;)

    Thanks for the tip.
     
    noppid, Jun 16, 2005 IP
  10. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,220
    Likes Received:
    778
    Best Answers:
    0
    Trophy Points:
    0
    #10
    T0PS3O, Jun 16, 2005 IP
  11. THT

    THT Peon

    Messages:
    686
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Yeah you can pass referer and User Agent in cURL

    Still cant bloody get adsense working :D
     
    THT, Jun 16, 2005 IP
  12. sarahk

    sarahk iTamer Staff

    Messages:
    25,335
    Likes Received:
    3,478
    Best Answers:
    101
    Trophy Points:
    665
    #12
    Use curl, it's clearly documented, easy to follow and it works.

    Post if you need help. I've done a bit of it.

    Sarah
     
    sarahk, Jun 17, 2005 IP
  13. THT

    THT Peon

    Messages:
    686
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #13
    heres my function:

    But it still doesnt work :


    function HTTP_Post($URL,$data, $referrer="") {

    // parsing the given URL
    $URL_Info=parse_url($URL);

    // Building referer
    if($referer=="") // if not given use this script as referer
    $referer=$_SERVER["SCRIPT_URI"];


    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,$URL_Info["host"].$URL_Info["path"]);
    curl_setopt($ch, CURLOPT_HEADER,0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch, CURLOPT_REFERER, $referer );
    curl_setopt($ch, CURLOPT_POST,1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    $result=@curl_exec ($ch);
    curl_close ($ch);
    return $result;
    }
     
    THT, Jun 17, 2005 IP
  14. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,220
    Likes Received:
    778
    Best Answers:
    0
    Trophy Points:
    0
    #14
    Check out the Class linked above. It's really dead-easy.

    Fill out the form variables (Install FireFox Web Developer Toolbar and go Forms - View Form Information) in the $form array, set the post data and it works.
     
    T0PS3O, Jun 17, 2005 IP
  15. chmac

    chmac Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #15
    Can you use curl or the http.inc script to "spoof" an IP address?

    I'm trying to pass names and emails to a Get Response auto responder as well as capturing them myself, so I figure the easiest option is to submit them to my own PHP script and then use my script to submit them to Get Response. However, the IP address stored with Get Response will be wrong. Is there any way I can pass through the user's original IP?
     
    chmac, Jun 24, 2005 IP