That is it but can I not set the session variable directly from the link? Something like.. print('<A href="' . $_SERVER['PHP_SELF'] . '?$_SESSION['switch=on']">Switch on</A><BR> ""Ivo F.A.C. Fokkema"" <I.F.A.C.Fokkema@xxxxxxx> wrote in message news:pan.2006.08.21.15.12.55.310164@xxxxxxxxxx > On Mon, 21 Aug 2006 13:08:04 +0100, Ross wrote: > >> I want to set a session with a text link, am having problems with the >> syntax. The link swiches the session to on or off. >> >> >> <a href="" class="link_text">swtich off</a> >> href="" class="link_text">swtich on</a> >> >> I want to do this but the syntax is incorrect. >> >> <?=$_SERVER['PHP_SELF']?$_SESSION['switch]='0'; ?> >> <?=$_SERVER['PHP_SELF']?$_SESSION['switch]='1'; ?> >> >> what is the correct syntax for this line? > > I am not too sure on what you're trying to do... but maybe this helps? > // Untested code! > > <?php > print('<A href="' . $_SERVER['PHP_SELF'] . '?switch=on">Switch on</A><BR> > '<A href="' . $_SERVER['PHP_SELF'] . '?switch=off">Switch > off</A><BR>'); > > if (isset($_GET['switch'])) { > // Set switch, as requested. > $_SESSION['switch'] = ($_GET['switch'] == 'on'? 1 : 0); > } > ?> > > Hope this helps anything... > > Ivo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php