切换到GET方法时FORM URL出现问题

I have a problem with creating a simple search form, used to search my database.

I started using the POST-method and everything worked fine, but switched to using GET-method instead to be able to bookmark my search results. But now I have trouble with the "action-url" when posting.

<form action="index.php?page=searchresult'" method="post">

This worked fine, I got my var's sent to the stated URL, but

<form action="index.php?page=searchresult" method="get">

Doesn't work. When I check my HTML code everything looks great, but I end up going to the URL

site.com/index.php?ALL THE GET-variables linedup here.

I am loosing the "?page=searchresult" part when using the GET-method?!

Am I missing something here, please help?!

Humble regards :)

If you are using GET methood then you can pass page parameter in hidden field like

<input type="hidden" name="page" value="searchresult">

You have a quote too much, try removing it.

                                         |   
                                        \|/
<form action="index.php?page=searchresult'" method="post">

GET sends data in the query string. If the URL in the action has a query string, it will be overwritten by the new one generated by the form.

Store your data in hidden inputs instead.

Well, this is interesting, but you can fix it using an hidden <input>, such as this:

<form action="index.php" method="get">
<input type="hidden" name="page" value="searchresult" />
            <input type="submit" value="submit" />
</form>

Just compile the "value" of the hidden input with what you need to pass.

Tried it and it actually works.

Edit:

obviously, from php, use this:

<?php $page = ((isset($_GET['page'])?($_GET['page']):("nope")); ?>

Add a hidden page data in the form.

<form action="index.php" method="get">
<input type="hidden" name="page" value="searchresult" />

Simply because "page=searchresult" is a get data.

Try changing this to

<form action="index.php?page=searchresult" method="get">

Put the page element as a hidden tag.

<form action="index.php" method="get">
<input type="hidden" name="page" value="searchresult"/>
<!-- Rest of the input elements -->
<input type="submit" />
</form>

This should fix your issue.