/    Sign up×
Community /Pin to ProfileBookmark

Changing PHP session Variables with buttons.

OK cool any idea how i can send a specific value over to a certain page but it should be a variable that is attached to a button.

i’ve tried assigning functions with a onclick but it dont seem to be working.

On my 1 page i have 1 picture to select so that is no hickup i can set the session variable in the main code but on my 2nd page i have 2 pictures that i want to direct to the same page and that page send them back to that one so…

if i select “select top picture” it should send a value over to that page and the page send it back then i want click “select bottom picture” and send that value over and then the other pages sends it back.

i want to use $_SESSION[‘PAGE’] = “prod1top” and $_SESSION[‘PAGE’] = “prod1bot” and then use a SWITCH to set the right session variable and send it back to the right page.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@NightShift58Mar 11.2007 — Ouch!

[B]If [/B] you must do it, then just use:[code=php]<?php
<a href="page2.php?img=top"><img src="/images/image_top.gif"></a>
<br>
<a href="page2.php?img=bot"><img src="/images/image_bot.gif"></a>
?>[/code]
On page2.php, manipulate the $_SESSION variable as required and redirect the user back to page1.php.

AJAX would be option for this as well.
Copy linkTweet thisAlerts:
@AarchaicauthorMar 12.2007 — Thanks but i just fixed it myself using another way..

the button had a form so all i did was add a hidden field to it

[code=php]
<input type="hidden" Name="PAGE" Value="PROD1TOP" >
[/code]


and on the next page i assigned the Session variable using...

[code=php]
$_SESSION['PAGE'] = $_POST['PAGE'];
[/code]


Thanks for your time and efforts ?
×

Success!

Help @Aarchaic spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...