Jump to content

Recommended Posts

Hi,

I woudl like to pass multiple variables from different forms into one url.

This is some of my code:

[quote]$merke_search = "%";
if (isset($_GET['var1'])) {
  $var1_search = (get_magic_quotes_gpc()) ? $_GET['var1'] : addslashes($_GET['var1']);
}

$smoke_search = "%";
if (isset($_GET['var2'])) {
  $var2_search = (get_magic_quotes_gpc()) ? $_GET['var2'] : addslashes($_GET['var2']);
}


mysql_select_db($database_db, $db);
$search = mysql_query("SELECT * FROM table WHERE name LIKE '%$var1_search%' AND course LIKE '%$var2_search%'", $db) or die(mysql_error());
$row_search = mysql_fetch_assoc($search);
$totalRows_search = mysql_num_rows($search);[/quote]

'var1' is from one form, and 'var2' is from another. How can I combine these two, so I can get a url like [b]page.php?var1=1&var2=2[/b] as a result? It works when I enter the full url manually, but I want the forms to generate the url.

I really hope you can help me out with this. I'd be thankful for any suggestions.  :)


The "form-code" is like this:
[quote]<form id="form1" name="form1" method="get" action="/v2/tools/pollista2.php">
    <label>
<? echo 'Name: '; ?>
    <input name="var1" type="text" id="var1" size="19" />
    </label>
</form>


<form id="form2" name="form2" method="get" action="/v2/tools/pollista2.php">
    <label>
<? echo 'Course: '; ?>
    <input name="var2" type="text" id="var2" size="19" />
    </label>
</form>[/quote]

When I fill in both forms, only the parameter from form2 is passed to the url, like [b]page.php?var2=2[/b], var1 is not included.
because when you press submit you submit what ever form that submit button is within.. why not send both values on 1 form then this will work fine??


[code]<form id="form1" name="form1" method="get" action="/v2/tools/pollista2.php">
      <label>
      <? echo 'Name: '; ?>
          <input name="var1" type="text" id="var1" size="19" />
      </label>
      <label>
      <? echo 'Course: '; ?>
          <input name="var2" type="text" id="var2" size="19" />
      </label>
</form>
[/code]
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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