i need your help.
I'm trying to save the checkbox values in a session and show, on a second php file. But the Session is in the second php file always NULL.
If i output the Session and the Post on the one.php, the array looks fine.
one.php
<?php
session_start();
?>
<!DOCTYPE html>
<html>
<body>
<h1>Show checkboxes:</h1>
<form action="two.php" method="post">
<input type="checkbox" name="vehicle[]" value="Bike"> I have a bike<br>
<input type="checkbox" name="vehicle[]" value="Car"> I have a car<br>
<input type="checkbox" name="vehicle[]" value="Boat" checked> I have a boat<br><br>
<input type="submit" value="Submit">
</form>
</body>
</html>
<?php
$_SESSION['test'] = $_POST['vehicle'];
var_dump($_POST['vehicle']);
echo "</br>";
var_dump($_SESSION['test']);
?>
two.php
<?php
session_start();
$arr = $_SESSION['test'];
var_dump($arr);
foreach($arr as $value)
{
echo $value;
echo "</br>";
}
?>
Aucun commentaire:
Enregistrer un commentaire