0

I have some problem with CURL to post data to URL. It not redirect to the action URL which I post the data. I have index.php file contains the CURL code and test.php which receive the post data. This is my index.php:

<?php

$url = 'http://localhost/curl/test.php';

$myvars = 'BASKET=123&AMOUNT=15000000';

$ch = curl_init( $url );
curl_setopt( $ch, CURLOPT_POST, 1);
curl_setopt( $ch, CURLOPT_POSTFIELDS, $myvars);
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt( $ch, CURLOPT_HEADER, 0);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 0);

$response = curl_exec( $ch );

?>

And this is my test.php:

<?php 
echo $_POST['BASKET'];
?>

When I'm trying to load index.php file I want redirect to the test.php and display the data but the problem is I'm still on the index.php page and not jump to test.php file. When I'm try use HTML Form it was fine but in this case I cannot use HTML Form because the data which I post is not from form input. Please anybody know how to that please help me. Thank you before.

Antonio
  • 755
  • 4
  • 14
  • 35

0 Answers0