使用curl收集数据,并通过表单将其发送到数据库

问题描述 投票:0回答:1

我已经搜寻了所有可以想到的东西来实现这一目标。我正在尝试通过curl收集数据,然后将该数据发送到将其提交到数据库的表单中。借助this blog和现有产品,我设法获得了以下代码]

//extract data from the post
//set POST variables

$cookie_name = "drcuserid";

if(isset($_COOKIE[$cookie_name]))
{
$cookie = $_COOKIE[$cookie_name];
}
$url = 'http://dirtrif.com/test.php';
$fields['username'] = $vbulletin->userinfo[username];
$fields['userid'] = $vbulletin->userinfo[userid];
$fields['addontitle'] = $info['title'];
$fields['addonversion'] = $info['version'];
$fields['bburl'] = $vbulletin->options[bburl];
$fields['bbtitle'] = $vbulletin->options[bbtitle];
$fields['webmasteremail'] = $vbulletin->options[webmasteremail];
$fields['cookie'] = $_COOKIE[$cookie_name];

//url-ify the data for the POST
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string, '&');

//open connection
$ch = curl_init();

//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);

//execute post
$result = curl_exec($ch);

//close connection
curl_close($ch);

这对我来说都是未知的领域,我知道需要将其提交到test.php上的表单,但是我不知道从哪里开始。我遇到的每个示例都没有包含该部分,甚至都没有提及。

我正在尝试将这些数据提交到我的数据库,然后从那里我可以管理提取结果。我知道这是非常苛刻的要求,但是如果有人能指出我正确的方向,那也将很棒。我不希望自己吃东西,但我想学习。

***************已添加****************

只是想弄清楚我正在寻找的结果将是一种获取我定义的变量,然后将它们发送到我定义的URL的方法,该URL将通过表单或其他任何方式将它们提交到我的数据库中将结果发送到我的数据库。

我试图实现的输出示例将是:(DATABASE TABLES)间距没有计算出来。希望你能理解。

用户名userid addontitle addonversion bburl

BOB 2产品v1.0 somesite.com

php arrays database forms curl
1个回答
0
投票

我已阅读THIS,这使我对使用curl有了更多的了解。要回答我的一个问题,curl是表单(至少是我收集的表单),现在来看是否可以弄清楚将其发布到数据库中。

© www.soinside.com 2019 - 2024. All rights reserved.