codingbbq
codingbbq

Reputation: 4179

Php page refresh , get the post values from formm

i got a jquery upload and crop script and i am trying to use it.

First i have a 1.html file which has a form, which requires some texts and image. After submitting the form it goes to main.php where it checks for some image properties and if successful it refreshes the page using header("location:".$_SERVER["PHP_SELF"]);

So if i place my $_POST['name'] i get the value from 1.html . Now when the image in displayed after page refresh there is one more option to select the thumbnail and upon selecting the thumbnail there is one more page refresh, to display the final images (both bigger and thumb). Now my problem is for second page refresh i am not able to get the fields which i had posted from 1.html. Any suggestion would be highly appreciated. Thanks

Upvotes: 1

Views: 2876

Answers (2)

Matteo Riva
Matteo Riva

Reputation: 25060

With that header refresh you are losing every information. Drop the refresh and do consecutive forms: you need to propagate the values you need from the first form, using hidden input fields in the forms that follow

<input type="hidden" value="<?php echo $value_from_original_post; ?>">

or you can store the value(s) of interests in session variable(s).

Alternatively, you can use an AJAX solution which requires no reload or page change, but it's a bit more work (and you might not want javascript).

Upvotes: 2

Trav L
Trav L

Reputation: 15202

You can not store states between pages unless:

  • Keep rolling the value(s) forward as hidden input type if it's a form submission.
  • Temporarily save value(s) as cookie until consumed.

Upvotes: 0

Related Questions