I am trying to connect to a php script on one server from another. This script is password protected with .htaccess. I am able to connect to it and I am able to execute it but I am not able to receive my post data variables on the other end. The code for accessing my remote script is as follows:
function do_post_request(){
$url = "http://www.testscript.com/admin/myscript.php";
$data = 'HWA=111111111111';
$header .= "Authorization: Basic " . base64_encode("username:password);
$params = array('http' => array('method' => 'POST', 'header' => $header, 'content' => $data));
$ctx = stream_context_create($params);
$fp = @fopen($url, 'r', false, $ctx);
if (!$fp)
return "Problem generating SN [1]";
$response = @fgets($fp, 1024);
if ($response === false)
return "Problem reading data";
return $response;
}
my script on the other end is executing the following code:
if (array_key_exists("HWA", $_REQUEST))
{
$HWA = $_REQUEST["HWA"];
echo myscript($HWA);
}
else
echo "No info";
This always returns 'No info' for me. I have tried using the $POST variable instead of the $REQUEST and that didn't work for me either. I am completely at a loss as to why the post data is not being populated.
QU
Moderator: General Moderators
Re: QU
Why dont you try
$data = implode('', file('http://www.example.com/'));
take the htaccess for now. Also, if your script produces no output without the correct password, do you need htaccess?
$data = implode('', file('http://www.example.com/'));
take the htaccess for now. Also, if your script produces no output without the correct password, do you need htaccess?
Re: QU
Im not sure what implode would do for me since I am not dealing with an array to my knowledge. Also my script is returning output based on an else statement if there is no post data. I only get connected to my script if there is the Authentication in my script.
Re: QU
reciever.php(notice not using post on example)
sender.php
Code: Select all
$n1 = $_GET['n1'];
$n2 = $_GET['n2'];
echo $n1+$n2;
Code: Select all
$data = implode('', file('http://localhost/test/receiver.php?n1=5&n2=7'));
echo $data;