-->

Automatically submitting a form with PHP Snoopy

2019-09-06 06:49发布

问题:

I am using the following code to automatically fill in a field and submit a form at another server:

<?php   
    include "Snoopy.class.php";
    $snoopy = new Snoopy;      
    $snoopy->agent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5 FirePHP/0.2.1";
    $snoopy->referer = "http://www.google.com/";
    $url = "http://example.com/?page=a";
    $data["field_name"] = "value";
    $snoopy->httpmethod = "POST";
    $snoopy->submit($url, $data);
    echo $snoopy->results;
?> 

The problem is that it does not work!

The source of the page http://example.com/?page=a is:

<form action="" method="post" class="horizontal-form" role="form" >
<input type="hidden" name="submit_form" value="true" />
<input type="text" name="field_name" class="form-control" value="" >
<button type="submit" class="btn"><i class="icon-ok"></i> Send</button>
</form>

Any idea how it can be fixed? Can it be that the "action" in the main page is empty?

Thank you for your help.

标签: php forms snoopy