Set default value if NOT set...

What I want to happen is when you first open the page http://www.mysite.com/index.php NOTHING should load in the div … right now, instead of leaving it empty, it will choose of the the colors to show.

At the top:

<?php ob_start(); session_start(); if(isset($_SESSION['div'])) { if($_GET["div"]!="") { $div = $_GET["div"]; $_SESSION["div"] = $div; } else { $div = $_SESSION["div"]; } } else { $div = $_GET["div"]; $_SESSION["div"] = $div; } ?>

LINKS ARE SET LIKE THIS: http://www.mysite.com/index.php?div=red


WHERE I WANT CERTAIN TEXT TO APPEAR ACCORDING TO WHAT THE LINKS SET:

<?php if($div=="red") {echo 'Red is 1';} elseif($div=="orange") {echo 'Orange is 2';} elseif($div=="yellow") {echo 'Yellow is 3';} elseif($div=="green") {echo 'Green is 4';} elseif($div=="blue") {echo 'Blue is 5';} elseif($div=="Purple") {echo 'Purple is 6';} elseif($div=="random") {echo 'Random';} elseif(empty($div)) {echo '';} else {echo '';} ?>

elseif(is_null($div))
{echo ‘’;}

This seemed to work at first, then once it was set, it remember it, even when I went back to the page without the div being set ???

Sponsor our Newsletter | Privacy Policy | Terms of Service