1

I have this code:

<? 
$page = $_GET['page'];
$find = $_GET['find'];
?>

<form method="post" action="#">
  <input type="text" name="whatever" value="1">
  <button class="btn btn-default" type="submit">Post this</button>
</form>

My initial URL is: htttp://www.someplace.com?page=1&find=lookfor

When sending the post form I am getting back "page" and "find" vars along the "whatever" input value. Why? Is this happening because my form action is "#"?

By the way, this is what I want, this saves me the work of posting hidden input values. But I want to be sure it is valid.

Nicoli
  • 643
  • 1
  • 7
  • 23

1 Answers1

2

Using action="#", you will submit the form to the current URL. Your GET vars are part of this URL so that is why you're getting them again.

More infos on this question.

Maarti
  • 3,600
  • 4
  • 17
  • 34