Re: setting a session with a text link?

From: Date: Mon, 21 Aug 2006 15:12:55 +0000
Subject: Re: setting a session with a text link?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-240949@lists.php.net to get a copy of this message
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

« previous php.general (#240949) next »