Forum Moderators: coopster

Message Too Old, No Replies

Programs With Styles

         

quozt

8:13 am on May 17, 2004 (gmt 0)

10+ Year Member



hello all, im trying to create a script where the user can change the background color of the page by clicking a link and that background color will say while they are visiting the site but im having a few problems.. im trying to use sessions but to no availe..

index.php

<?php
session_start();
session_id("555");
if (!isset($_SESSION['style']) )
{
$_SESSION['style'] = "red";
}
if ( isset($_GET['style']) )
{
$_SESSION['style'] = $_GET['style'];
}
?>
<html>
<head>
<title>Testing</title>
</head>
<body bgcolor="<?=$_SESSION['style'];?>">
Current color: <?=$_SESSION['style'];?>
<br />
<a href="index.php?style=red">Red</a>
<a href="index.php?style=green">Green</a>
<a href="style.php">Style</a>
</body>
</html>

then we move to another page

style.php

<?php session_id("555");?>
<html>
<head>
<title>Project Random :: Carrots or Cabbage</title>
</head>
<body bgcolor="<? echo ( $_SESSION['style'] );?>">
You selected <? echo ( $_SESSION['style'] );?>
<p>
</p>
</body>
</html>

style.php is just blank and doesnt output the variables set by the index... does anyone have any ideas

venelin13

9:58 am on May 17, 2004 (gmt 0)

10+ Year Member



Hi, instead of using:

session_id("555");

just put

session_start();

at the top of each file.