Automatically submitting a form with PHP Snoopy

旧城冷巷雨未停 提交于 2020-01-06 19:15:23

问题


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.

来源:https://stackoverflow.com/questions/30538532/automatically-submitting-a-form-with-php-snoopy

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!