要检查登录的卷曲

时间:2015-07-14 02:06:47

标签: php curl

我正在尝试使用PHP脚本来放置登录名和密码并测试正确的用户名和密码,有人可以告诉我我该怎么做吗?

username=user1, password=passuser1, gender=1

到example.com

之后,我假设curl会回复给我一个回答,这是正确的还是OK。

Note: the process must be done more than 20 or 30 times.

1 个答案:

答案 0 :(得分:1)

我会告诉你如何做到这一点,但是我不会为你做这件事,因为你试图强行建立一个网站而我无法帮助你,但这只是一个例子:

<?php
//
// A very simple PHP example that sends a HTTP POST to a remote site
//

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL,"http://www.example.com/tester.phtml");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
            "postvar1=value1&postvar2=value2&postvar3=value3");

// in real life you should use something like:
// curl_setopt($ch, CURLOPT_POSTFIELDS, 
//          http_build_query(array('postvar1' => 'value1')));

// receive server response ...
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$server_output = curl_exec ($ch);

curl_close ($ch);

// further processing ....
if ($server_output == "OK") { ... } else { ... }

?>

如果您需要更多示例,可以查看PHP手册:http://php.net/manual/en/book.curl.php

相关问题