Jump to content

_GET and REQUEST_URI complict?


bugzy

Recommended Posts

I have a form get like this

 

<form action="<?php echo $_SERVER['REQUEST_URI']."&";  ?>" method="get" name="search">

 

that form is for example on www.mywebsite.com/search.php?cat=1001

 

if I click submit button, I'm expecting this

 

www.mywebsite.com/search.php?cat=1001&search=textbox_anything

 

 

But it is always redirecting me to

 

www.mywebsite.com/search.php?search=textbox_anything

 

It is removing the cat=1001

 

 

Is there any alternative?

Link to comment
https://forums.phpfreaks.com/topic/266367-_get-and-request_uri-complict/
Share on other sites

If you set method=get then the query string in the action URL will be overwritten with whatever the form data is.

 

It looks like all you're expecting is the category ID? Put that in a hidden field.

</pre>
<form action="search.php" method="get" name="search">
" /><

Uh, I posted something potentially very bad. Try again:

<form action="search.php" method="get" name="search">
<input type="hidden" name="cat" value="<?php echo (int)$_GET["cat"]; ?>" />

XSS

 

Just a question, so (int) is necessary to increase security on every numeric data that will be pass on the url? are htmlentities and urlencode also suitable for this?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.