I am having allot of trouble trying to get an array to work with sessions if anyone can help that would be great I'm not bothered about validation etc if I can just get it working i can then expand upon it.
HTML
<form method="post" action="array2.php">
Select amount of tickets you require.
<select name="options[]">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
Select the acomidation you require.
<select name="options2[]">
<option value="camping">Camping</option>
<option value="caravan">Caravan</option>
</select>
<input type="submit" value="Go!" />
</form>
array2.php
<?php
session_start();
$checked = $_POST['options'];
$checked2 = $_POST['options2'];
$_SESSION['user'] = true;
$_SESSION['checked'] = $checked;
$_SESSION['checked2'] = $checked2;
header('Location: array3.php');
?>
array3.php
<?php
session_start();
if(!isset($_SESSION['user'])){
die("To access this page, you need to <a href='register.html'>LOGIN</a>");
}
$checked = $_SESSION['checked'];
$checked2 = $_SESSION['checked2'];
?>
<?php
for($i=0; $i < count($checked && $checked2); $i++){
echo "You have selected to receive " . $checked[$i] . " tickets<br/>";
echo "And you have selected to receive " . $checked2[$i] . " for accommodation are you sure? <br/>";
}
?>
The main problem is that the values are not being passed from array2 into array3, any help is welcomed.
EDIT - this worked fine until I tried to add in the sessions to get it working over multiple pages so I'm sure thats where the problem is
EDIT2 - thanks for all the help guys i got it working when I took out
$checked = $_POST['options'];
$checked2 = $_POST['options2'];
From array 3 it worked :) much appreciated!
array2& not inarray3? , if you can cross check for me.print_r($_SESSION)return in array3.php?