tags:

views:

81

answers:

2

Hello,

I've been working with PHP lately, and I came across something I couldn't solve.

So basically, I have a form:

<form method="get">
    <fieldset class="display-options" style="float: left">
    Search by name or ip:
        <input type="text" name="key" value="" />&nbsp;
        <input type="submit" class="button2" value="Search" />
    </fieldset>
</form>

The problem is, I currently already have a argument:

http://example.com/logs.php?type=admin&amp;page=1

How would i pass the given form argument with the already existing arguments? Like so:

http://example.com/logs.php?type=admin&amp;page=1&amp;key=name

Thanks in advance, AJ.

+4  A: 

<snip />

EDIT: hidden fields is your best and most reliable option.

<input type="hidden" name="var1" value="<?php echo $_GET['var1']; ?>" />

Place a couple of those in your <form> element and they'll get passed along with the other data.

You shouldn't need an isset() but it might be a good idea.

Christian Mann
Better you edit your answer to leave only one working solution with hidden fields :)
Col. Shrapnel
your <snip> tag isn't properly formed.. should be `<snip />` 8p
intuited
I suppose if I use XHTML in my snippet, I should use it in my documentation as well.
Christian Mann
+1  A: 
if (isset($_GET['key'])) {
    $_print_r($_GET);
}

This should have the query string and the fields.

Brant