Forum Moderators: coopster

Message Too Old, No Replies

Displaying What The Guest Is Using

         

Programmers

6:41 am on Jul 7, 2006 (gmt 0)

10+ Year Member



On my website I have 3 skins. I also have a commenting system where the guests can make comments on recent news.

I would like to implement something so that I, and the other users can see what skin is being used by everyone else. Hopefully, it would look something like this:

Comment By Programmers (Using the red skin)
" c o m m e n t "

I have just sat and wrote my first ever if statement, and it works. However, it never occoured to me that I wrote it to display my own skin. How can I pick up, and display what skins others are using?

Here's what I just wrote, incase it comes in handy:

<?php
$skin = $_COOKIE['myskin'];

if ($skin == "1") {
echo "Using the red skin";
} else if ($skin == "2") {
echo "Using the blue skin";
} else if ($skin == "3") {
echo "Using the purple skin";
} else {
echo "Using the red skin";
}
?>

Any help would be greatly appreciated.

Regards,
Tom.

eelixduppy

9:32 am on Jul 7, 2006 (gmt 0)



Retrieve their skin cookie and add it to the table in your database(or where ever you store the comments) when the user submit the form, not when a user reads the comment. Have a try at this first to see where you get. Something like this:


//user submits form already
$user = $_SESSION['user']; //Are you using sessions for this?
$text = $_POST['text'];
if(isset($_COOKIE['myskin'])) {
$skin = ($_COOKIE['myskin']-1);
$skin_colors = array [us2.php.net]("red","blue","purple");
$skin = $skin_colors[$skin];
}
else { $skin = "red"; }
//Insert info to DB, using above info

I used an array just to show you another way. Good luck ;)