Jump to content

Sessions


m_tyhurst2002

Recommended Posts

Hi guys, newb here, trying to get sessions to work form me. I am having difficulty incorporating SESSIONS into my dynamic SELECT OPTION.

 

At the very top of my page I am starting SESSION code and POSTing "people" from the form.

 

<?php session_start(); // start session 
$totalpeople = $_POST['people']; //post number of tanks from form ?>

 

This is my SELECT OPTION code.

 

<select name="people">
		<?
			for ($i=1;$i<100;$i++)
			{
				$selected = "";
				if ($i==$totalpeople)
						$selected = (isset($_SESSION['people']) && $i == $_SESSION['people']) ? ' selected' : '';
					print ("<option value='" . $i . "' " . $selected . ">" . $i . "</option>\n");
			}
		?>	
            </select>

 

Any help or insight would be greatly appreciated!

Link to comment
Share on other sites

I have one page actually, the first option that appears on that page is a SELECT dropdown where they select how many people, and submit. When they submit, it reloads the same page with other options (the first option goes away after submitting). The new options, when clicked on, goes to a PayPal cart. From that cart, when they click "continue shopping" it reloads my page and the user has to select how many people again. I would just like it if the SELECT OPTION remembered how many people they chose the first time. Hope that makes sense.

Link to comment
Share on other sites

Bad move, you need to secure the $_POST[] before you throw it into a session. any posted data from a user should be checked/cleaned & made secure. Failing to do so a user can inject code into the post, cause a lot of damage depending on what you have running in your php & what the person injects.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.