Re: setting a session with a text link?
| From: | Ross | Date: | Mon, 21 Aug 2006 16:01:55 +0000 |
| Subject: | Re: setting a session with a text link? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-240955@lists.php.net to get a copy of this message | ||
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@LUMC.nl> wrote in message
news:pan.2006.08.21.15.12.55.310164@LUMC.nl...
> 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