Jump to content

Isset Problems


timothyarden

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/265376-isset-problems/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/265376-isset-problems/#findComment-1360030
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/265376-isset-problems/#findComment-1360031
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.