timothyarden Posted July 8, 2012 Share Posted July 8, 2012 Hi Everyone In the following code I'm getting an error with the isset in my error log. if(isset($_COOKIE['user'])) { echo "<p>Logged in as".$_COOKIE['user']."</p>"; } else { echo "You are currently using AGG as a <a href='index.php?page=guests explained' alt='Explains what a guest is and how you are limited in the sites functionality'>Guest.</a>" } Just wondering what I'm doing wrong. Any ideas or help are appreciated. Timothy Quote Link to comment https://forums.phpfreaks.com/topic/265376-isset-problems/ Share on other sites More sharing options...
Barand Posted July 8, 2012 Share Posted July 8, 2012 The "alt" attribute in the <a>...</a> tag needs to be "title" Quote Link to comment https://forums.phpfreaks.com/topic/265376-isset-problems/#findComment-1360016 Share on other sites More sharing options...
timothyarden Posted July 8, 2012 Author Share Posted July 8, 2012 Okay, I will change. Just wondering why though - when the user hovers on the link doesn't the alt attribute have the text that explains what it links to? Thanks for your help and hope to hear from you soon, Timothy Quote Link to comment https://forums.phpfreaks.com/topic/265376-isset-problems/#findComment-1360017 Share on other sites More sharing options...
Barand Posted July 8, 2012 Share Posted July 8, 2012 ALT - used in image tags to supply alternative text if image does not load. TITLE - provides tool-tip text when mouse is over the element. Quote Link to comment https://forums.phpfreaks.com/topic/265376-isset-problems/#findComment-1360019 Share on other sites More sharing options...
timothyarden Posted July 8, 2012 Author Share Posted July 8, 2012 Thanks for the info. I have changed it. Have you got any ideas for my other problem? Timothy Quote Link to comment https://forums.phpfreaks.com/topic/265376-isset-problems/#findComment-1360027 Share on other sites More sharing options...
requinix Posted July 8, 2012 Share Posted July 8, 2012 Depends what the error is, because (a) isset() practically never throws any kinds of errors ever and (b) that code you posted is fine. Besides the alt/title thing. And missing a space between the "an" and the username. And that one branch of the if outputs a block-level element while the other branch outputs text. And HTML injection because cookies come from the user and cannot be trusted. And I'm a bit concerned that you may be using cookies as your only authentication mechanism without validating the username and/or credentials first. Mostly fine. Quote Link to comment https://forums.phpfreaks.com/topic/265376-isset-problems/#findComment-1360030 Share on other sites More sharing options...
timothyarden Posted July 8, 2012 Author Share Posted July 8, 2012 Thanks everyone for your help. I found my error. (Scroll Across Below) $cookieuser = $_COOKIE['user']; if(isset($cookieuser)) { echo "<p>Logged in as ".$_COOKIE['user']."</p>"; } else { echo "You are currently using AGG as a <a href='index.php?page=guests explained' title='Explains what a guest is and how you are limited in the sites functionality'>Guest.</a>" //// I forgot to put the semi-colon here to finish the statement. } Thanks heaps for your time and effort. Timothy Quote Link to comment https://forums.phpfreaks.com/topic/265376-isset-problems/#findComment-1360031 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.