Jump to content

how to remove get vars from url


purencool

Recommended Posts

hi phpfreaks

 

I am trying to remove the get variables from my url.  the code below works if  I echo it out but to try to modify the $_server variable it will not work. Any ideas?

 

 

$current_url = explode('?',$_SERVER["REQUEST_URI"]);
$_SERVER["REQUEST_URI"]= $current_url[0];
echo $current_url[0]."<br>";

Link to comment
Share on other sites

Sorry for the late rely. To answer kenrbnsn question. The reason for doing this is I have a multiple forms on one page if I update the page with one of the forms then displays the get vars. So what I have been doing is putting the get vars into normal vars and then trying to remove the get vars so that they don't display in the url.

 

Thanks for your replys so far. I hope that this answer your questions.

Link to comment
Share on other sites

if you're doing it for security reasons, then it's useless.

 

_GET and _POST can always be manipulated by the user. If you're trying to hide it from the user it's also useless. I say let the user see the url, it makes no difference. If you're code if properly validated, then you have nothing to worry about. The only thing I must say is always use POST to get a password because using GET will sometimes leave the password in the url history. It would make more sense to ask for help on improving your forms and validation.

Link to comment
Share on other sites

Sorry for the late rely. To answer kenrbnsn question. The reason for doing this is I have a multiple forms on one page if I update the page with one of the forms then displays the get vars. So what I have been doing is putting the get vars into normal vars and then trying to remove the get vars so that they don't display in the url.

 

Thanks for your replys so far. I hope that this answer your questions.

 

The method you should use depends on what you're trying to do.

 

If you're passing data in to simply retrieve related info (e.g., using an id number to retrieve a product from the db), use get, a.k.a., query string appended to the end of a URL.

 

If you're passing data in to insert/update/edit something, use post.

 

This will keep your site semantically correct.

Link to comment
Share on other sites

wow I just want to keep it clean but why don't  just use post vars  :-[

If you want to keep it clean and not change the URL, I would suggest using Javascript.

 

Set the page that you post to on a whole 'nother page, and use JQuery/AJAX to post to it and return false to the function to keep it from refreshing your page.  You can then use JQuery to change the value of a div to "Successfully Updated", or whatever you wish upon success, or if failed have it display that there as well.

Link to comment
Share on other sites

wow I just want to keep it clean but why don't  just use post vars  :-[

 

I guess I'm just not entirely clear as to why you need to keep the address clean.  I'm getting the feeling that your design may be flawed.

 

Also, if you're scrubbing the address, why wouldn't you want to use post instead?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.