Lady_452 Posted August 20, 2007 Share Posted August 20, 2007 Ok I'm a n00b yada yada (lol)... I have a .htm page on which I want to add a PHP script that will display links depending on if the user is in session or not. I'm not sure if this can be done on a strictly .htm page, but hey you only live once right? Here's the script I'm attempting to execute: <? if ($_SESSION['auth'] == "yes"){ ?> <a href="/index.php?page=sign_in">Sign In</a> <? }else{ ?> <a href="index.php?page=logout">Logout</a> <? } ?> The problem is that I don't know all the back-end php coding for the 3rd party s/w I'm using, but since the design calls for a "main .htm page" that displays all the "include" pages, having 2 links displaying on the same page seems silly (1 link for login and anohter for logout). So how can I combine these links and have them display depending on the session state of the user? Or is there a better way of accomplishing this all together? Thanks much for any help given. Quote Link to comment https://forums.phpfreaks.com/topic/65885-best-way-to-add-a-php-element-to-an-html-page/ Share on other sites More sharing options...
Daniel0 Posted August 20, 2007 Share Posted August 20, 2007 You can do it in .htm pages. You just need to setup the server up to do so: AddType application/x-httpd-php .htm (httpd.conf or .htaccess) Other than that I really don't understand your question. Quote Link to comment https://forums.phpfreaks.com/topic/65885-best-way-to-add-a-php-element-to-an-html-page/#findComment-329350 Share on other sites More sharing options...
dbillings Posted August 21, 2007 Share Posted August 21, 2007 I'm not following why you want the page to say htm either but you could make the page say .taco if you wanted to, but if the web server isn't set up to know that taco is an alias for php it won't work. You can't just use a standard old html page to run php. I think you simply have the links setup backwards the following will show logout if the session variable auth equals yes (I assume that means logged in.). Then if it doesn't equal yes it will provide the Sign In link. <? if ($_SESSION['auth'] == "yes"){ ?> <a href="index.php?page=logout">Logout[/url] <? }else{ ?> <a href="/index.php?page=sign_in">Sign In[/url] <? } ?> Quote Link to comment https://forums.phpfreaks.com/topic/65885-best-way-to-add-a-php-element-to-an-html-page/#findComment-329427 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.