nezbo Posted November 12, 2007 Share Posted November 12, 2007 Hi all I have a bit of a dificault one. i am using php and mysql to verify the login's, and i am using a .js file for nav menu's, but i want to use a php to let people see what menus that they are allowed to see. hope this make sence... e.g. i have a "edit user" page in a nav menu dropdown and i dont want any body to see it apart from the administrators. Neil Quote Link to comment Share on other sites More sharing options...
Dragen Posted November 12, 2007 Share Posted November 12, 2007 You could try AJAX, but I'm not sure if it'd work, as I'm not very good at it, or you could simply add a couple of lines to your .htaccess file: RemoveHandler .js AddType application/x-httpd-php .php .js That will allow all .js files on your server to run php as well. Although, unlike .php files, I think if someone views the source code of the .js file they would see the php code.. not sure though. Quote Link to comment Share on other sites More sharing options...
Vikas Jayna Posted November 12, 2007 Share Posted November 12, 2007 A javascript file can be served through php also. The php file can simply process and decide what should be the javascript code and simple throw that code to the browser. The following line will have to be added to the top of the php file in order to tell the browser that the content is javascript: header("Content-type: application/x-javascript"); Also, the file extension can be kept .js and mod_rewrite can be used in apache to direct the file to a php file like this: RewriteRule ^abc.js$ abc.php [T=application/x-httpd-php] The above line cab be used in .htaccess. This way the browser will call file "abc.js" but actually "abc.php" will be executed on the server. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.