php - Unable to store session data into next form -


Currently I'm on a question to store the session and pass it in the next form, but I started the session I try and store the variable within the session, it does not work. Please put some light on this, thanks!

MainForm.php

  & lt ;? Php session_start (); Required ("inputValidation.php"); // This php file is just a file that is $ validForm = true; If ($ _POST) {}? & Gt; & Lt; Form class = "form" action = "nextform.php" role = "form" method = "post" & gt; & Lt; Input type = "text" class = "form-control" id = "name" name = "name" value = "& lt; php if (isset ($ _ POST ['name'])) {if (validatedRequired ( $ {_POST ['name'])) {$ _SESSION ['test'] = $ _POST ['name']; $ validation = false;} if (valid ($ _ POST ['name'])) {$ _SESSION ['Test'] = $ _POST ['name']; $ validfo = true;}}? & Gt; input name = "submit" type = "submit" value = "submit" class = "  

nextform.php

  print_rate ($ _SESSION);   / Pre> 

The problem is even when I enter any value inside the text box name, I It will be redirected right now to advance without the value of my session. Why is that so? Is there any way that I can get my session value by changing action = "nextform.php" ?

Sorry, I'm still new to sessions and PHP, bear so much with me :)

  (ifet ($ _ POST ['name'])) {//. In your case,  nextform.php . 

should be your page

something like:

MainForm.php

  & lt; Form class = "form" action = "nextform.php" role = "form" method = "post" & gt; & Lt; Input type = "text" class = "form-control" id = "name" name = "name" value = "" & gt; & Lt; Input name = "submit" type = "submit" value = "submit" class = "btn btn-primary" & gt;  

nextform.php

   

Basically you can add POST parameter where the form is submitted, see action = "nextform.php"

Here you can check whether the form submit With either the need to redirect the user elsewhere, or just show the proper message, either validation failed or validation success .

< / Div>

Comments