I'm using Codeigniter Framework and I want to do something like this:
I want send $_GET
varibale from server 1 to server 2, like this: www.server1.com?foo=123
AND now on server 2, check if the $_GET==123
return some data.
My code look like this that:
on server 1, example: www.server1.com?foo=hello
if(isset($_GET['foo'])){
$post_fields = array(
'foo' => $_GET['foo']
);
$ch = curl_init('http://server2.com/master.php');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
curl_setopt($ch, CURLOPT_POST, 1);
$result = curl_exec($ch);
die($result);
}
and the code on server 2 look like this:
$variable = $_POST['foo'];
if($variable=="hellow"){
echo "right!";
}else{
echo "wrong";
}
When I run this code I'm getting 400 bad request - nginx: