0

I have searched everything I can think of to make this happen. I am trying to collect data through curl, then send that data to a form which submits it to the database. With the help of this blog and a pre existing product, I managed to get the following code

//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);

This is all uncharted territory to me, and I know it needs to be submitted to a form on test.php but I have no idea where to even start with it. Every example I have come across fails to include that part or even speak of it.

I am trying to get this data submitted to my database, then from there I can manage pulling the results. I know this is pretty demanding, but if anyone can point me in the right direction that would be awesome too. I'm not looking to be spoon-fed I do want to learn as I evolve.

***************Added**************

Just wanted to clarify the results I'm looking for would be a way to get these variables I defined, then send them to my URL I defined, Which would submit them to my database through a form, or really any other way of sending the results to my DB.

An Example of the output I am trying to achieve would be: (DATABASE TABLES) spacing didn't work out. Hope you understand.

username userid addontitle addonversion bburl

BOB 2 Product v1.0 somesite.com

DrCustUmz
  • 370
  • 3
  • 15
  • Does https://stackoverflow.com/questions/2138527/php-curl-http-post-sample-code help? – Nigel Ren Jun 06 '20 at 14:39
  • @NigelRen no, I came across that one, I didn't see anything involving a form. That's really the part I'm stuck at. The contents I need in test.php is what I cant figure out, which seems would have a form within it where the variable defined in the code displayed would be submitted. – DrCustUmz Jun 06 '20 at 14:48
  • Something like https://stackoverflow.com/questions/13276226/generate-url-with-parameters-from-an-array to generate the data for the URL. – Nigel Ren Jun 06 '20 at 14:49
  • Again appreciate the help, but I'm failing to see how that is a form... I will update the original post. – DrCustUmz Jun 06 '20 at 14:51
  • Where is the form in your code? – Nigel Ren Jun 06 '20 at 14:54
  • read my message again – DrCustUmz Jun 06 '20 at 15:01

1 Answers1

0

I have read THIS which gave me more insight to working with curl. To answer one of my questions, curl is the form (at least what I gathered) Now on to seeing if I can figure out this posting it to my DB.

DrCustUmz
  • 370
  • 3
  • 15