dreamwest Posted November 21, 2008 Share Posted November 21, 2008 can i use php within head tags?? im trying to adjust pages based on cookies <head><?php if (isset($_COOKIE['visual_nav'])) echo ""; else echo "<link rel=\"stylesheet\"/style.css\" type=\"text/css\" />"; { if ($_COOKIE['visual_nav'] === 'off') echo "<link rel=\"stylesheet\"/style2.css\" type=\"text/css\" />"; elseif ($_COOKIE['visual_nav'] === 'on')echo "<link rel=\"stylesheet\"/style3.css\" type=\"text/css\" />"; } ?></head> <body></body> Quote Link to comment https://forums.phpfreaks.com/topic/133622-can-i-use-php-within-head-tags/ Share on other sites More sharing options...
JasonLewis Posted November 21, 2008 Share Posted November 21, 2008 Of course. You can use it above the head tags, which I often do, as that's where session_start() and a lot of other things need to go. Quote Link to comment https://forums.phpfreaks.com/topic/133622-can-i-use-php-within-head-tags/#findComment-695171 Share on other sites More sharing options...
wtfsmd Posted November 21, 2008 Share Posted November 21, 2008 Yes you can. On my website my users can change their styles in their profile storing their options in the MySQL database i then use their SESSION variables along with their MySQL information to change the style sheet and save a cookie for when they visit the site but are not logged in. Quote Link to comment https://forums.phpfreaks.com/topic/133622-can-i-use-php-within-head-tags/#findComment-695173 Share on other sites More sharing options...
MasterACE14 Posted November 21, 2008 Share Posted November 21, 2008 PHP can go pretty much anywhere. Quote Link to comment https://forums.phpfreaks.com/topic/133622-can-i-use-php-within-head-tags/#findComment-695176 Share on other sites More sharing options...
dreamwest Posted November 21, 2008 Author Share Posted November 21, 2008 Yes you can. On my website my users can change their styles in their profile storing their options in the MySQL database i then use their SESSION variables along with their MySQL information to change the style sheet and save a cookie for when they visit the site but are not logged in. I haven't started learning how to develop mysql databases from scratch yet , would this be faster than using php directly?? Quote Link to comment https://forums.phpfreaks.com/topic/133622-can-i-use-php-within-head-tags/#findComment-695188 Share on other sites More sharing options...
mtoynbee Posted November 21, 2008 Share Posted November 21, 2008 If you learn MySQL you will still need PHP to interface with it on the web. http://uk2.php.net/mysql Quote Link to comment https://forums.phpfreaks.com/topic/133622-can-i-use-php-within-head-tags/#findComment-695220 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.