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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.