Show custom query page based on user logged in I want to make a customized query page based on the user who is logged in. The query page is a node made in custom made content type "query"(this content type has no additional fields than which are created in a new default content type)

I have a &lt;p id = my_para&gt; tag in my node. I call an external query.js script in my node which uses xmlHTTPRequest to call an external query.php. This php connects with mysql and does a query like

select * from my_table where user = "logged-in-user";


and returns the query result using json_encode back to query.js. The query.js parses json and displays it on my node using document.getElementById("my_para").innerHTML = my_parsed_json_variable

So I some how want to get the logged in user details(there can be many logged in users to mysite at the same time) so that each user can see a custom page through these scripts.

How can I get the user details in my external query.php ? 
I tried using these in my query.php

global $user;
$name = $user-&gt;name;
$id = $user-&gt;uid;


But it gives 


  Trying to get property of non-object in
  C:\xampp\htdocs\mywebsite\sites\all\themes\danland\query.php
If your page is being created via code, then you can check the role of the user via code and not display the filters you want.

Otherwise, you may want to create different query pages for different roles and enable the right page for the right role using a module that restricts access such as the 'node access' module.