views:

759

answers:

2

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

+2  A: 

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).

kemp
thanks, i used session to get the data on page refresh. Thanks for your reply.
noobcode
A: 

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.
rockacola
can i have two forms on the same page.Both the forms action go to the same page. Does it sounds logical?
noobcode
Nothing will stop you from having 2 forms in same page, however you will have some trouble differentiate which form got submitted as only 1 will be. The common practise for wizard-like pages (where you fill in details and click next for several pages) is to use cookie/session for small data volume or database for larger.
rockacola