Jump to content

PHP Curl POST & Referer & Redirect


Hex

Recommended Posts

Hi I wrote curl script for post datas to website but i have problem. For example when u go http://xxxsite.com/?cid=119 on your web page it will redirect to http://xxxsite.com/register and I need to post datas to http://xxxsite.com/register page. but it reject my request cauz I'm not coming from ?cid=119 page. I tried do it with curl referer like I was coming from ?cid=199 but it still rejects. I need to post datas to /register page but curl must go first to ?cid=119 page. It will get ?cid data and other thing then will post my datas to register how can i do this ? here my php codes :

<?php

$ch = curl_init();
$site = "http://xxxsite.com/?cid=119";
curl_setopt($ch,CURLOPT_REFERER,$site);
curl_setopt($ch, CURLOPT_URL, 'http://xxxsite.com/register');
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, 'yazi=deneme');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$store = curl_exec ($ch);
echo $store;
curl_close ($ch);

?>

Link to comment
https://forums.phpfreaks.com/topic/117528-php-curl-post-referer-redirect/
Share on other sites

Erm, well what happens when you normally browse to ?cid=119. Are you sure the processing is not being done there before being forwarded to /register?

 

It could be that something is being set in a session when you visit ?cid=119. In that case, you'll have to make two requests. The first will access ?cid=119 and save the session ID (you'll have to provide the CURLOPT_COOKIEJAR option. The second will be to /register.

Archived

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

×
×
  • Create New...

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.