How to fill and submit forms in PHP

Status
Not open for further replies.

bubbles

Domainers...
Apr 11, 2007
858
27
0
Can anyone point me in the right direction to fill and submit forms in php?

Smaxor had a link to it in his sig... I checked his site, and the page was blank. Then I PM'd him and haven't gotten a reply yet, figured someone else would know.
 


Best advice I can give you. Download lerchmo's page gen and rotator script. Get the bot class from that, then use the following template to submit to forms, simple and you can parse whatever info you get on the other end
Code:
<?php
include ('bot.php');
$bot = new Bot;
$data = array('formName', 'formValue');
$form = $bot->post('formURL', $data);
// Use $form to parse the data recieved
?>
Enjoy :)
 
  • Like
Reactions: bubbles
Here's the modified version of that class.

PHP:
class Curl
{    
    function setup()
    {        
        $cookieJar = 'cookies.txt';
        curl_setopt($this->curl, CURLOPT_HEADER, 1);
        curl_setopt($this->curl, CURLOPT_COOKIEJAR, $cookieJar); 
        curl_setopt($this->curl, CURLOPT_COOKIEFILE, $cookieJar);
        curl_setopt($this->curl, CURLOPT_AUTOREFERER, true);
        curl_setopt($this->curl, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($this->curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4');
    }
    
    function clean($contents)
    {
        return $contents = str_replace('<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAA6ElvpTmZs4PUpZpSAoK6BSHXJsp5oogWH5jZodYSc2VMsh-GBSvecccQD_seEoYLmo-SsWfitQQEw" type="text/javascript"></script>', '', $contents);
    }
    
    function get($url)
    { 
        $this->curl = curl_init($url);
        $this->setup();
        return $this->clean($this->request());
    }
    
    function getAll($reg,$str)
    {
        preg_match_all($reg,$str,$matches);
        return $matches[1];
    }
    
    function postForm($url, $fields, $referer='')
    {
        $this->curl = curl_init($url);
        $this->setup();
        curl_setopt($this->curl, CURLOPT_URL, $url);
        curl_setopt($this->curl, CURLOPT_POST, 1);
        curl_setopt($this->curl, CURLOPT_REFERER, $referer);
        curl_setopt($this->curl, CURLOPT_POSTFIELDS, $fields);
        return $this->request();
    }
    
    function getInfo($info)
    {
        $info = ($info == 'lasturl') ? curl_getinfo($this->curl, CURLINFO_EFFECTIVE_URL) : curl_getinfo($this->curl, $info);
        return $info;
    }
    
    function request() 
    { 
        return curl_exec($this->curl); 
    }
}
 
lol you don't need to modify it, lerch did a great job at it, very versatile
 
Yeah I do, lerch's doesn't have form posting capabilities. :D

BTW, are you sure lerch made it? I was talking to someone else who had a very similar one.

Regardless, it's proved invaluable to me.
 
+rep, thank you all... Exactly what I needed! To bad the world will now be worse off because of it!!!1 MUA AHHAHAHAHAHHAHAHAHHAHAHAHHAHAHAHAHHAHAHAH
 
Status
Not open for further replies.