Currently I am on a question to store session and pass it to the next form, but as hard as I try to start session and store the variable inside the session, it does not work. Please shed some light on this, thanks!
MainForm.php
<?php
session_start();
require("inputValidation.php"); // This php file is just a file that does validation for my side
$validForm = true;
if ($_POST)
{
}
?>
<form class="form" action="nextform.php" role="form" method="post">
<input type="text" class="form-control" id="name" name="name" value= "<?php
if (isset($_POST['name']))
{
if (!validateRequired($_POST['name']))
{
$_SESSION['test'] = $_POST['name'];
$validForm = false;
}
if (validateRequired($_POST['name']))
{
$_SESSION['test'] = $_POST['name'];
$validForm = true;
}
}
?>
<input name="submit" type="submit" value="Submit" class="btn btn-primary">
nextform.php
print_r ($_SESSION);
The problem is even if i enter any value inside the textbox name, I will be just redirected straight to nextform.php without getting my session value. Why is this so? Is there any way I can get my session value without changing action="nextform.php"
?
Thank you!
Sorry I am still new to sessions and PHP so bear with me :)