Welcome to WebmasterWorld Guest from 34.204.191.31

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Programs With Styles

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

Junior Member

10+ Year Member

joined:Apr 11, 2004
posts:71
votes: 0


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

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

Junior Member

10+ Year Member

joined:Apr 16, 2004
posts:96
votes: 0


Hi, instead of using:

session_id("555");

just put

session_start();

at the top of each file.