0

Hello all, hope you can help me understand, here's the general description:
I have a form, 'frmData' that has a hidden field, that when submitted it sends the info to process.php, which checks if the hidden field has been submitted, if so it redirects the user to a page "energy.php" which also checks if the hidden field has been submitted since it needs to assure that the previous form was filled, if the hidden field wasn't submitted it displays a link to the form.

The Problem is:
That when we visit the "energy.php" page without submitting the form it displays the link to th form correctly, but, when we visit the form, fill it and submit it "energy.php" keeps displaying the link to the form instead of the content that has to be shown when the user submitted th form correctly, I checked the $_POST and it shows it empty upon submitting the form, here's the simplified code files.:

Form.php
Contains the form to be submitted.

<form name="frmData">
   <input type="hidden" name="hddData" value="1" />
   <input name="bttSubmit" type="submit" id="submit" value="Calculate"/>   
</form>

process.php
This file handles all processes.

<?php
   if( isset($_POST['hddData']) )
   {   
      /*Calculate stuff*/
      header(Location:energy.php);
   }
?>

Energy.php
If user arrives at this page before the form has been submitted, it displays a link redirecting to the form.

<?php
   if( isset($_POST['hddData') ) 
      include "info.php"; /*Form has been submitted correctly, include external file*/
   else
      echo "<h4 class=\"center\">No data, please submit data <a href=\"form.php\">here</a></h3>";/*if the form hasn't been submitted*/
?>

My opinion:
It seems that the $_POST is unset after process.php checks for its existence, since I echoed the variable on process.php and it shows it's value (1), but when process.php redirects the user to energy.php, energy.php shows the message that the form has not been submitted, even if the form has been correctly filled.

Any help is truly appreciated.

regards, Tristian

Edited by Triztian: n/a

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by Triztian
0

The redirect doesn't repost the data.

The best solution is to avoid the redirect. Otherwise You can store the variable in cookie/session or pass it as get parameter (which will work with the redirect);

0

Hey thank you, that was the answer, now storing the hddData in a session variable, it works just fine.
Solved.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.