Jump to content

Sessions Keep Changing


mister_t101

Recommended Posts

I am trying to create a script with a multidimensional array. On each form submission, a new element is added to the array with the form info.

The problem is that every time the form is submitted, a new session is created. I have looked online, but I can't seem to find the answer to this specific problem. I have two other pages that operate in the same way without any problems.

I'm sure the answer is simple, but I'm just too frustrated to see it.

Thanks in advance

Here's the code...

php:
<?php
session_start();
print session_id()." session id<br />";
print "<br />";
print count($_SESSION['multi'])." count - session MULTI<br />";
print "<br />";
$_SESSION['checkFrameAll'];
$_SESSION['sessionFrameAll'];
$_SESSION['multi']= array();

if (array_key_exists('_submit_check', $_POST)) {

$multiProduct = $_POST['multiProduct']; //put form elements into variables
$multiSize = $_POST['multiSize'];
$multiQuantity = $_POST['multiQuantity'];
$trioColor = $_POST['trioColor'];
$trioQuantity = $_POST['trioQuantity'];

if ($multiProduct ==1)
{
$multiProduct1 = $_POST['hTrio1'];
$multiProduct2 = $_POST['hTrio2'];
$multiProduct3 = $_POST['hTrio3'];
}

if ($multiProduct ==2)
{
$multiProduct1 = $_POST['vTrio1'];
$multiProduct2 = $_POST['vTrio2'];
$multiProduct3 = $_POST['vTrio3'];
}

if ($multiProduct ==3)
{
$multiProduct1 = $_POST['hMulti1'];
$multiProduct2 = $_POST['hMulti2'];
$multiProduct3 = $_POST['hMulti3'];
}

if ($multiProduct ==4)
{
$multiProduct1 = $_POST['vMulti1'];
$multiProduct2 = $_POST['vMulti2'];
$multiProduct3 = $_POST['vMulti3'];
}

$formArray=array($multiProduct,$multiProduct1,$multiProduct2,$multiProduct3);
foreach ($formArray as $tempArray)
{
print $tempArray;
print "<br />";
}
$_SESSION['multi'][] = $formArray;

foreach ($_SESSION['multi'] as $tempArray)
{

if($tempMultiArray[0] == 1 || $tempMultiArray[0] == 2)
{
print $key." Trio<br />";
}

else
{
print $key." Multi<br />";
}

print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Your First Pose is: '.$tempMultiArray[1] . "<br />\n";
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Your Second Pose is: '.$tempMultiArray[2] . "<br />\n";
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Your Third Pose is: '.$tempMultiArray[3] . "<br />\n";
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Product Quantity is: '.$tempMultiArray[4] . "<br />\n";

if($tempArray[0] == 1 || $tempArray[0] == 2)
{
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Trio Style: '.$tempMultiArray[5] . "<br />\n";
}

else
{
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MultiSize: '.$tempMultiArray[5] . "<br />\n";
}
}
}
?>
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.