Jump to content

Archived

This topic is now archived and is closed to further replies.

UrbelT

PHP Curl w/ form name...

Recommended Posts

I am trying to run a curl to emulate the following form: http://peterl.storefrontx.com/list/index.php?p=subscribe&id=2

I don't know if its the <form> name tag, or the hidden list[2] and listname[2] tags that are messing it up but its not working. Can anyone tell me what curl postfield vars I should use to properly emulate the post?

Thanks!

[code] $postfields = 'p=subscribe&id=2&email='.$_POST['email'].'&emailconfirm='.$_POST['email'].'&list[2]=signup&listname[2]="Lambrou\'s Newsletter"';
$url = "http://peterl.storefrontx.com/list/index.php";
// initialise Curl
$popPost = curl_init();
curl_setopt($popPost, CURLOPT_URL, $url);
// Set Curl Option: Username:Password
curl_setopt($popPost, CURLOPT_POST, 1);
// Set Curl Option: Collect result from script
curl_setopt($popPost, CURLOPT_RETURNTRANSFER, 1);
// Set Curl Option: Set timeout to 15 seconds
curl_setopt($popPost, CURLOPT_TIMEOUT, 15);
// Set Curl Option: Post data
curl_setopt($popPost, CURLOPT_POSTFIELDS, $postfields);
// Execute Request, and store result in $tb_post
$popPost_result = curl_exec ($popPost);
// Close Curl
curl_close ($popPost);[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.