heldenbrau Posted August 6, 2009 Share Posted August 6, 2009 I want to inlude some php includes in my shtml files. I have the following line added in the head section of my shtml page. <MIME TYPE Extension application/x-httpd-php.html> But when I open the page, the php doesn't work. The code is not displayed though, it is only displayed in the source. The code that is in the include is <?php session_start(); if (!isset($_SESSION['username'])) { $username=($_SESSION['username']); echo"You are logged in as $username"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/169071-php-includes-in-shtml-files/ Share on other sites More sharing options...
trq Posted August 6, 2009 Share Posted August 6, 2009 I suggest you post your question in the apache board. Quote Link to comment https://forums.phpfreaks.com/topic/169071-php-includes-in-shtml-files/#findComment-892042 Share on other sites More sharing options...
alex3 Posted August 6, 2009 Share Posted August 6, 2009 You need to tell Apache (assuming that's what you are running) to let the PHP parser parse the page. Put this in your .htaccess file RemoveHandler .shtml AddType application/x-httpd-php .php .shtml The 'x-httpd-php' part may be different on your server. When I was on a free host, there had different tiers of PHP security, so some people used x-httpd-phpv2 on so on. If the example above doesn't work, you'll have to check with your host. Also remember that that .htaccess file when apply to every sub-directory from the directory it's in as well. Quote Link to comment https://forums.phpfreaks.com/topic/169071-php-includes-in-shtml-files/#findComment-892045 Share on other sites More sharing options...
heldenbrau Posted August 6, 2009 Author Share Posted August 6, 2009 I am using apache on my laptop to test a website. It is version 2.2. I have added those lines to the httpd file. It has made an improvement, the code is displayed on the webpage, but the code isn't executed. It is like it is being done in the wrong order, like PHP first, then shtml, so the php is included after it has been exectuted, so only shows as an html page with the php code. Quote Link to comment https://forums.phpfreaks.com/topic/169071-php-includes-in-shtml-files/#findComment-892178 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.