質問

I have a file called "receive_data.php" on my server, that receives POST data from excel vba constantly throughout the day. This file inserts data into the database as a log of which tools and reports are being used throughout the day for the business I work for.

I have now created a report that is generated onscreen when php file "show_data.php" is viewed.

When show_data.php is viewed, ideally I would like to 'ping' "receive_data.php" with similar values as below:

$_POST['code'] = 1;
$_POST['r_id'] = 24;

The company I work for uses very old browsers, therefore using something like AngularJS is not an option as it can be unreliable in anything older than IE9.

I could include "receive_data.php" within the php file, but it's still a case of being able to have the variables sent in as 'post' variables.

I could modify the "receive_data.php" file to accept variables, however...

Ultimately I do not want to modify "receive_data.php" in any way, if at all possible.

If this is possible, then great! If not, then I will have to look at modifying the file, but due to the business intensive needs, editing it is worse for us.

役に立ちましたか?

解決

You can try something like this:

if( $curl = curl_init() ) {
    curl_setopt($curl, CURLOPT_URL, '<path_to_your_script>/receive_data.php');
    curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, "code=1&r_id=14");
    $out = curl_exec($curl);
    echo $out;
    curl_close($curl);
  }
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top