PHP CURL help needed

General discussions related to php

Moderators: macek, egami, gesf

kiddie12
New php-forum User
New php-forum User
Posts: 1
Joined: Thu Nov 08, 2012 12:26 am

PHP CURL help needed

Postby kiddie12 » Thu Nov 08, 2012 12:31 am

What will be the CURL postfields of this html form in php.


<form method="post" action="update-cart.php?action=do-update… name="upgrade" class="upgrade">
<input type="hidden" id="updatecart" name="updatecart" value="35b35rt45" />
<input type="hidden" name="http_referer" value="/cart/update-cart.php" />
<p><input id="upgrade" class="button" type="submit" value="Upgrade by click here" name="upgrade" /></form>



I have tried it , but no result : -


$urlto=('mysite.com');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $urlto);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,"upgrade=Upgrade by click here");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch,CURLOPT_RETURNTRANSFER…
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch, CURLOPT_COOKIEJAR, "COOKIE.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, "COOKIE.txt");

$buffer = curl_exec($ch);



Can someone tell me that , What is the correct postfields ? please

johnj
php-forum Super User
php-forum Super User
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: PHP CURL help needed

Postby johnj » Thu Nov 08, 2012 8:12 am

You can try this:
$data = array('updatecart' => '35b35rt45', 'http_referer' => '/cart/update-cart.php');
curl_setopt($ch, CURLOPT_POST, 2);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);


Return to “PHP General”

Who is online

Users browsing this forum: No registered users and 1 guest