Some php help needed

7 public posts in this discussion.

Post 2

look at the $_POST or $_GET variables, depending on what submit method your form uses, they will contain all the information in the form, with the field names as the array keys.

Post 3

Quote from paladin;383848:
look at the $_POST or $_GET variables, depending on what submit method your form uses, they will contain all the information in the form, with the field names as the array keys.

this is the code for the form
<form action="includes/clothing.inc.php" method="POST">

is this what you mean?

clothing.inc.php
//store session of baby tshirt
$_SESSION['size1'] = $_POST['babytsize']; <<--babytsize is the name of the html select box.
$_SESSION['color1'] = $_POST['babytcolor'];

//store session of baby singlet
$_SESSION['size2'] = $_POST['babysingsize'];
$_SESSION['color2'] = $_POST['babysingcolor'];

//store session of baby shorts
$_SESSION['size3'] = $_POST['babyshortsize'];
$_SESSION['color3'] = $_POST['babyshortcolor'];

//store session of baby bibs
$_SESSION['size4'] = $_POST['babybsize'];
$_SESSION['color4'] = $_POST['babybcolor'];

not sure, i could be completely wrong

Post 4

yeah clothing.inc.php receives the contents of the form when you hit submit. you can store arrays in session variables, would be a lot cleaner than doing size1, 2, 3, 4 etc.

to get an idea of what the $_POST variable contains, i'd suggest temporarily making your clothing.inc.php file just do this:

[php]
<?php
print_r($_POST);
?>
[/php]

Post 5

Quote from paladin;383850:
yeah clothing.inc.php receives the contents of the form when you hit submit. you can store arrays in session variables, would be a lot cleaner than doing size1, 2, 3, 4 etc.

to get an idea of what the $_POST variable contains, i'd suggest temporarily making your clothing.inc.php file just do this:

[php]
<?php
print_r($_POST);
?>
[/php]

Yeah thanks for that, apparently i missed out a "." from the location of where the form was suppose to go. I got that temp page up to see how the values are being passed along.
Your right about size1, 2,3,4 its very messy. You said "you can store arrays in session variables" how would i go about starting that.?

Post 6

[PHP]$cart_array=array('val1', 'val2', 'val3', 'val4', 'val5');

$_SESSION['cartitems']=$cart_array;[/PHP]

or you can probably do something like this:

[php]

$peeny_array=array($_POST['babytsize'],$_POST['babytcolor']); <<--babytsize is the name of the html select box.

//store session of baby singlet
$not_so_peeny_array=array($_POST['babysingsize'],$_POST['babysingcolor']);

//store session of baby shorts
$less_peeny_array=array($_POST['babyshortsize'],$_POST['babyshortcolor']);

//store session of baby bibs
$un_peeny_array=array($_POST['babybsize'],$_POST['babybcolor']);

//set cart and session array
$cart_array=array($peeny_array, $not_so_peeny_array, $less_peeny_array,$un_peeny_array);

$_SESSION['cartitems']=$cart_array;

[/php]

i think..

Post 7

well without getting into classes, your clothes have a name, a size and a colour right? in which case something like this:

[php]
$item['type'] = "t-shirt";
$item['colour'] = $_POST['babytcolour'];
$item['size'] = $_POST['babytsize'];

$_SESSION['items'][] = $item;

$item['type'] = "bib";
$item['size'] = $_POST['babybsize'];
$item['colour'] = $_POST['babybcolour'];

$_SESSION['items'][] = $item;
[/php]

and so forth.