My local Windows 10 Apache2.4 and PHP 7 server has a file with the following code ( output.php )
<?php
file_get_contents("https://www.MY-WEB-ADDRESS.com/dir/index.php");
?>
My remote server MY-WEB-ADDRESS has a file at /dir/index.php with the following code
<?php
include $_SERVER['DOCUMENT_ROOT'].'/res/databin/key.php';
if ( isset($_GET['sid']) ){
$sid = $_GET['sid'];
$query = "SELECT * FROM data WHERE data_id = '$sid'";
$result = mysqli_query($mydb, $query);
if ( $result && mysqli_num_rows($result) > 0 ){
$row = mysqli_fetch_assoc($result);
echo $row['data_id'];
}
else{
echo "-1";
}
}
else{
echo "-1";
}
?>
I have checked the local and remote servers PHP.ini to ensure allow_url_fopen is enabled. I've restarted my local webserver and also ensured that my HTTPS wrapper is enabled. I always get the following message
Warning: file_get_contents(h ttps://www.MY-WEB-ADDRESS.com/dir/index.php): failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in C:\Apache24\htdocs\dir\output.php
As I'm not passing the "sid" argument I would expect to receive a -1 but all I get is the output error above. What else can I check to make this work? The data is supposed to output in nothing but plain text with no formatting.
EDIT I have also tried calling file_get_contents without using HTTPS