How do I hide the variables so I have a cleaner URL?Instead of the one below?
test.php?id=1&mainid=1
I looked up some thing for .htaccess but I'm still learning so I am stuck.
You'd need to use POST
instead of GET
if you wanted to do this. GET
, by its nature, puts the parameters in the URL.
Amber is right, change your form method to POST. You could try using
<input type="hidden" name="parameter_name" value="value_to_post" />
To pass the variables if you don't want them to be present in the URL but need them passed for processing. Keep in mind, though, that someone who views the source of your form will see the tags and can potentially discern the information you are passing, even with hidden fields.
If you are posting data that is to be used for generic processing and not for database manipulation GET is sufficient; regardless of method, if the data in the variables is going to be used against or put into a database, make sure to escape it to prevent SQL injection attacks (exploited most commonly through forms using the GET method).
Hope all this helps.
Use method post instead get...
Assuming that your site is hosted on an Apache server you can use mod_rewrite to get a nicer looking URL.
for example:
RewriteRule /products/([0-9]+) /siteengine/products.php?id=$1
With that line in your .httaccess you could access any product with:
example.com/products/N
Check out this tutorial