0

I have page name customer.php in this page, I have to call gift.php with query string. And gift.php page has a form set to auto submit. I have try this using CURL but it gives 404 error. And using php file_get_contents this one also redirect to 404. And tried using jQuery Ajax, I haven't got any result, But Its working with iframe, but I belive it is not the best option

<iframe src="gift.php?name=John"></iframe>

Could someone please help me to do this using curl...

this code not working

$url =urlencode('gift.php?name=john');

$header = array("Accept: application/json");

$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)');

$retValue = curl_exec($ch);
$response = json_decode(curl_exec($ch));
$ee       = curl_getinfo($ch);
print_r($ee);

print_r($retValue);
3
  • 1
    So where is the code? Commented Jun 13, 2014 at 8:31
  • @hindmost the code is not loading after save the question, when i go to edit mode, its visible Commented Jun 13, 2014 at 8:33
  • You have to set CURLOPT_URL option with absolute url. 'gift.php?name=john' is a relative url Commented Jun 13, 2014 at 8:39

1 Answer 1

1

For curl don't use $url =urlencode('gift.php?name=john'); and $url must contain domainname. For example $url = 'http://domain.com/gift.php?name=' . urlencode('john');

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.