Here is my code,
//I have set formData array to session array here
$_SESSION['form_data'] = $formData = array();
//here i have set a value to formData array
$formData[0] = 'insert data done';
//I want to accually echo the value of formData[0] - key's value
$var = $_SESSION['form_data'][$formData[0]];
var_dump($var);
I’m new to php and my requirement here is to build a form validation and send the validation data back to the form. So I use the session to send data to one php file to another. I think that’s the only way I can send data from one page to another.
The right order is:
But for form validation, you don’t need to redirect to the input page if validation failed.
Instead, just use the same template (html content), and render the page with error message, this way, you don’t need to send data back to the input page.