Jump to content

Embarrassing question


eggerda

Recommended Posts

Hello,

 

I'm a beginner, and I told someone I knew more than I did...now I've got to figure this out.

 

This is simple for anyone that knows what they are doing...and unfortunately, I don't.

 

Basically I need the simplest code to accomplish the following:

 

When a visitor comes to a page, I need to check for a cookie... if the cookie is empty I need to write out a line of html code (a tracking image).  If the cookies has an "X" value in it, I don't want to display the line of html code (the tracking image).

 

This is supposedly easy, but I've been struggling to get it to work write.

 

How would you do it?

 

Any thoughts are appreciated.

 

Thanks,

 

Dan

Link to comment
https://forums.phpfreaks.com/topic/56120-embarrassing-question/
Share on other sites

the answer is also here

 

When a visitor comes to a page, I need to check for a cookie... if the cookie is empty I need to write out a line of html code (a tracking image).  If the cookies has an "X" value in it, I don't want to display the line of html code (the tracking image).

 

and

if the cookie is empty

{

write out a line of html code

}

else

{

display the line of html code (the tracking image)

}

you've already answered your question

Link to comment
https://forums.phpfreaks.com/topic/56120-embarrassing-question/#findComment-277208
Share on other sites

Yes, but I'm having a hard time writing the code...it's just not working... I don't know what I'm doing wrong.

 

At the top of the page I have:

 

<?

if (empty($_COOKIE['TrackThis'])) {

$code = "http://trackingcode.com";

setcookie("TrackThis", $random_number, time()+60*60*24*30*12);

        }

?>

 

The in the body I have:

 

<? echo $code ?>

 

What did I do wrong?

 

Dan

Link to comment
https://forums.phpfreaks.com/topic/56120-embarrassing-question/#findComment-277212
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.