execute change variable only on click

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
neojo
Forum Newbie
Posts: 4
Joined: Fri Aug 12, 2005 4:14 pm

execute change variable only on click

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
neojo
Forum Newbie
Posts: 4
Joined: Fri Aug 12, 2005 4:14 pm

Post by neojo »

ok. but the receiving page is in the cgi-bin which doesn't execute php ... or can it??
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

it may.. test it.
Post Reply