php session help

Hi,

I am very new at php coding. I have some experience with HTML and CSS. I seem to be stuck.

I have 8 circle images. I want my user to choose 1 to 8 of the circles and then I want their choices to appear on a second page.

Is this possible with sessions? I get that I will need an if statement…if selected then use red.png on second page if not selected then use tranparent.png on second page.Is there a better way to do this?

I can’t seem to figure out how to allow for multiple selections of the circles.

My goal is to have the user pick multiple colors and have those colors passed to a second page.

Sorry if this is unclear. I don’t have any code to share yet because I’m just trying to figure out where to start.

Thank you for your patience and your help.

Lisa

Sure sessions/cookies is one of doing and probably the simplest way of doing.

pseudo code

[php]if sessions equals orange then
goto page 2
else
Sorry, you are not allowed[/php]

If you run into problems with the code, I’m 99.9 percent sure someone here would be glad to help you out.

You could probably also throw in a little bit of JavaScript and/or total javascript for there are cookies with JavaScript as well.

The simplest way is to just use a form with check boxes and POST the data to the second page. No need for Sessions, Cookies or Javascript.

[php]




[/php]

Page2
[php]<?php
if (isset($_POST’red’)){
echo ‘Red Selected
’;
}
if (isset($_POST’green’)){
echo ‘Green Selected
’;
}
?>[/php]

I agree with Kevin, you don’t need sessions for that when a form is just as easy to deal with.

My offering

Well using a form would be the easiest, but the way I was reading it as if the user was going to actually select the color circles. :wink:

Though a form could be used that way though I would use radio button ( though a checkbox could be used ) and do something like this - I did this quick and dirty, but I’m sure you could get it where the background color changes hue or something like that?

No JavaScript used:
https://jsfiddle.net/Strider64/37egL3kk/

Using a form is probably still more elegant, but JavaScritpt(JQuery) can be just as easy or quick. :wink:

Though I personally would use JavaScript (I use jQuery Library) to trigger the form submission, you can always fall back on HTML if a person has JavaScript disabled.

Where sessions or cookies would come into play is if you didn’t want to have the user continuously have to choose? Can make it as simple or complex. That is why I aways say it’s best to learn HTML/CSS first and get that down pat. Just my .02 cents. ;D

Sigh, I have to learn to read better…checkboxes would be better to use than radio buttons and probably easier to get the circles to do what you want it to do…sigh ::slight_smile:

Thank you to all. I really appreciate the help. I think I have an idea of where I need to start.

I’ll probably be back as I go further in this project.

Lisa

Sigh, I have to learn to read better.....checkboxes would be better to use than radio buttons and probably easier to get the circles to do what you want it to do...sigh

Just one additional point, using radio buttons, your options are only “One or the other”, check boxes are “One to many” options.

Sponsor our Newsletter | Privacy Policy | Terms of Service