Page 1 of 1

execute change variable only on click

Posted: Sat Aug 13, 2005 3:38 pm
by neojo
I thought this would be pretty straightforward, but it's not working...

I want to change the value of a session variable ONLY if the link is clicked on, however php seems to be executing every <? , so my variable is always the value of the last one on the page (eg. in the code below it is always "test2".

<A HREF="../cgi-bin/teddytest/index.cgi" class="class1" TARGET="_parent" <? $_SESSION['teddy']="test1";?> ><SPAN CLASS="body">teddy test1</SPAN></A>

<A HREF="../cgi-bin/teddytest2/index.cgi" class="class1" TARGET="_parent" <? $_SESSION['teddy']="test2";?> ><SPAN CLASS="body">teddy test2</SPAN></A>

i would pass the variable via the url but this is a little add on to site uses iframes and it was not working that way.

Posted: Sat Aug 13, 2005 3:50 pm
by feyd
you can't modify a session from the client-side only the server-side, as your evidence shows. You'll have to do something on the recieving page with the session.

Posted: Sat Aug 13, 2005 4:05 pm
by neojo
ok. but the receiving page is in the cgi-bin which doesn't execute php ... or can it??

Posted: Sat Aug 13, 2005 4:22 pm
by feyd
it may.. test it.