Facebook User ID blank when opening a PHP script
<p>Having difficulty with a Facebook User ID. Index.php opens, user is logged in and I have assigned $loggedinuser as the $user. I can stay in the same php document and use the variable okay. At the bottom of index.php, there is a include_once link;</p>

<pre><code>$page   =   isset($_REQUEST['page']) ? $_REQUEST['page'] : "home.php";
include_once "template.php";
</code></pre>

<p>Then the problem begins. The variable $loggedinuser is empty if I call it from within the template.php script.</p>

<p>Thanks for the explanation in advance.</p>

<p>In index.php file, I have;</p>

<pre><code>$loggedinuser = "$user";

global $loggedinuser;

$page   =   isset($_REQUEST['page']) ? $_REQUEST['page'] : "home.php";
include_once "template.php";
</code></pre>

<p>Then template.php is mostly javascript functions, some html with an onclick to call a php file called newuser.php</p>

<pre><code>               &lt;div onClick="newuserfunc();"
              style="position:absolute;display: block; cursor:pointer; top: 100px; left: 600px;"&gt;
              &lt;img src="assets/invite.png"&gt;
              &lt;/div&gt;
            function ajaxfunc()
</code></pre>

<p>{
        jQuery.ajax({
            type: "GET",
            url: "newuser.php",
            data:   "queryfields",
            success: function(html){</p>

<pre><code>        }
    });
</code></pre>

<p>}</p>

<p>In the newuser.php file the original variable $loggedinuser is blank;</p>

<pre><code>&lt;?php       






        $hostname="";
        $username="";
        $password="";
        $dbname="";
        $usertable="";

        $connection = mysql_connect($hostname, $username, $password);
        mysql_select_db($dbname, $connection) or die ("Could not connect");





        // Insert a row of information into the table "userdata"
        mysql_query("INSERT INTO userdata 
        (id, name, startdate, enddate, info) VALUES('$loggedinuser' , 'GB', '$startdate' , '$enddate' , 'test' ) ") 
        or die(mysql_error());  
</code></pre>

<p>?></p>
