I have a site that uses a GET form to assign a zip code to a user, and then the distance Based on that entry if no postcode is present, it only displays all the results.
My code works great The problem is that when I change from page 1, I lose my query string.
For other technical reasons, I can not use the POST method, especially I need to save this query state in some way and check the URL of the requested page, and it is empty Question string if it is empty.
Any thoughts on how to do this? The site uses a lot of jQuery, but I'm not sure there is a way to remember this string on jQuery's many strings. The site uses PHP as well, I have no problem in storing results in the PHP session variable and then rebuilding the URL, but I was hoping it would be slightly more straightforward than that. Thank you for your thoughts
Blue
I think that for this kind of The best option is to use continuous data one session. Your code checks for two things, a GET value and a session value we assume that both are present, then you accept GET. This allows the user to submit a new one and override the old.
session_start (); $ Zip = ''; If ($ _GET ['zip']) // // validate zip as required zip $ zip = $ _GET ['zip']; $ _SESSION ['zip'] = $ zip; } Otherwise ($ _ session ['zip']) {$ zip = $ _SESSION ['zip']; } Else {// default default case} Anytime, your PHP code needs to reference zip codes for queries, etc., $ zip Use the value in In this way you do not trust the page to deal with zip values - you store it server seams and need it any time.
Comments
Post a Comment