-3

**i need use this file php Variables post server on url **

http://example.com/addData.php   (the other server)
-------------------------------------
$a_player1 = $_POST['a_player1'] = 1;            
$a_player2 = $_POST['a_player2'] = 3;

 htto://srore.com/getdata.php
 -------------------------------------
include("http://example.com/addData.php");
echo $a_player1;
echo $a_player2;

error ???

Notice: Undefined variable: a_player1
Notice: Undefined variable: a_player2

php.ini settings then allow_url_include On

aofdev
  • 1,772
  • 1
  • 15
  • 29
  • 1
    If both files are in same folder no need to use ""http://...../test/", just use include("addData.php"); – jophab Jul 28 '16 at 16:39

2 Answers2

1

You're including via an absolute URL (which is a hideously bad security problem), which means you're EXECUTING that "remote" php script, and loading its OUTPUT, not the php code it contains.

And if allow_url_fopen is disabled, then nothing gets loaded anyways, and no php code will be seen, because that url is never hit.

If that file is on the same server/site as your main one, then do NOT use a url, a simple include('addData.php') will do.

Marc B
  • 356,200
  • 43
  • 426
  • 500
  • thanks you u misapprehend http://example.com/addData.php (the other server)--------------------------------------------------- htto://srore.com/getdata.php ------------------------------------- include("http://example.com/addData.php"); echo $a_player1; echo $a_player2; **error ???** Notice: Undefined variable: a_player1 Notice: Undefined variable: a_player2 – aofdev Jul 28 '16 at 17:04
-1

What you are looking for is something like a REST API. Something like: Creating a REST API using PHP

Community
  • 1
  • 1
Architect Nate
  • 674
  • 1
  • 6
  • 21