Jump to content

Recommended Posts

I am building a member-based website, and I've got a bunch of buttons that lead from page to page. The links for these buttons are generated based on user ID and subsequent pages receive this variable as well.

 

So, if you hover over the buttons, you get a link like this:

 

http://www.mysite.com?id=423

 

How can I hide the last part?  The '?id=423'?  I must use this format of variable, and cannot resort to session variables.  Is there a way to hide this portion of the links??

Link to comment
https://forums.phpfreaks.com/topic/250675-hiding-_get-variables/
Share on other sites

I have no idea how to set the method to POST from GET ...

 

I think if you use this format:

 

http://www.mysite.com?id=432

 

then the method is GET by default (and might always be GET).

 

Looks like we both need a smart person to verify, because I don't qualify for this level of verification.  ;)

You have a <form> tag somewhere. In this <form> tag, you should have a method attribute, so that your form tag will have <form method="get">. If you don't have this method attribute, you need to set it, and set it to post: <form method="post">. You will also have an action attribute in the tag, but I left this out of my explanation as it's not relevant. The relevant part is that you need method="post" in your form tag.

I do not have a form.

 

I am passing variables using the URL.

then no, you can't 'hide' it, if the data is that sensitive it shouldn't be passed through the URL in the first place. But I really don't think that's the issue is it? I have hunch you're not cleaning, filtering or validating the data and hence are having issues with cheeky users. In which case, work out how to do that as opposed to working around what you have, which clearly works.

MasterACE14,

 

You're right, in a sense.  I am not cleaning, filtering, or validating (CFV) data ... YET.  Right now I am working on the basic functions.  The CFV of data will be worked on at a later stage.  I was just hoping to be able to hide the variables that are being sent via URL; that would make it a little more difficult for malicious users to mess with the site.

POST ideally shouldn't be used for simply retrieving information anyway.  While POST and GET behave similarly (aside from GET data always being visible in the address bar), they have different meanings, and should be used accordingly.  Besides, one of the benefits of GET is that the results can be bookmarked.

 

That said, you can make your links look more pretty by using .htaccess.  So, instead of something like example.com?user=1138 you could have example.com/users/1138.

I was just hoping to be able to hide the variables that are being sent via URL; that would make it a little more difficult for malicious users to mess with the site.

 

Note that using $_POST isn't that much more secure. For example, someone could just download your form code; tamper with it; point it to where the form is normally submitted; click the submit button. It may not be as quick as messing with the $_GET variables, but it's not that complicated.

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.