Jump to content
  • Advertisement
Sign in to follow this  
Brainx7

How to remove GET variables from URL in php

This topic is 1432 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a form that uses method GET, to process the information, but then in the process.php  the URL it shows all the variables,

How can I remove this from the URL, don't tell me to use the POST method because I can't because of other reasons, I tried some solutions that I found online but none of them work, if you are going to give an example of how you solve this, don't show it in pseudo code, give me a real example

 

Or maybe hiding instead of removing?

 

The reason why I cant use post is because on process.php I have a button that exports the site to a word document, if I use post the input is not shown in the word document because the browser cannot make a request twice

Edited by Brainx7

Share this post


Link to post
Share on other sites
Advertisement

The reason why I cant use post is because on process.php I have a button that exports the site to a word document, if I use post the input is not shown in the word document because the browser cannot make a request twice

An alternative is to try solve the highlighted problem. Are you referring to a "This form has already been submitted" message (or however they are worded now)? To make the request twice, indicates you've made the request once. Is the page containing this control itself generated via POST?

 

You might notice, browsing the Internet, that you rarely see the sort of messages. This is because what most sites do is, like Ectara mentions, redirect to GET after POST. That is, when you submit a new thread to a site like gamedev.net, the response to your POST is "thanks, please GET http://www.gamedev.net/topic/987654-whatever-topic" (note: simplified, but that is the basic idea). The browser automatically navigates there, and the result is that if you use browser navigation you do not get such messages.

 

It would seem the ideal solution to your problem is to store the submitted state on the server somehow, in a database or just the session as Ectara suggests, so that it remains available for subsequent GET requests.

Edited by rip-off

Share this post


Link to post
Share on other sites

Well, all the GET parameters can be "hidden" if you used an Ajax query. Everything will be sent to the server, the user just won't see it in the URL of their browser.

 

GET is usually used when you want the URL to be unique, e.g. for printing coupons, etc. I don't remember ever having a problem with POST, either.

 

Just look up XMLHttpRequest, and the libraries that make it easier (jQuery was the framework of choice a few years ago, I have no idea if Angular does AJAX too, as I haven't done Web programming for an year to two).

Share this post


Link to post
Share on other sites

Well, all the GET parameters can be "hidden" if you used an Ajax query. Everything will be sent to the server, the user just won't see it in the URL of their browser.

 

GET is usually used when you want the URL to be unique, e.g. for printing coupons, etc. I don't remember ever having a problem with POST, either.

 

Just look up XMLHttpRequest, and the libraries that make it easier (jQuery was the framework of choice a few years ago, I have no idea if Angular does AJAX too, as I haven't done Web programming for an year to two).

 

It's a little better to think of GET as "a request that changes nothing" and POST as "a request that changes things". A different GET requests at different times of day to different or the same URLs on the server may return different results, but only because of some other, outside influence. The previous GET requests cannot be the reasons why the future ones are different, i.e. GET is read-only. There are other HTTP verbs, but they are mostly out of fashion/only useful for WebDAV (which is itself mostly out of fashion). 

 

So, submitting a form, almost always should be a POST, unless it's very clear that the form is selecting navigation elements. But then, forms mostly shouldn't be used as navigation elements.

 

To the OP, I urge you to please take the time to learn how to do the correct thing here. Don't hack in a solution. Start here: http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!