Jump to content


Photo

Multiple parameters in url from multiple forms?


  • Please log in to reply
2 replies to this topic

#1 bskauge

bskauge
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 07 September 2006 - 10:28 AM

Hi,

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

This is some of my code:

$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);


'var1' is from one form, and 'var2' is from another. How can I combine these two, so I can get a url like page.php?var1=1&var2=2 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:

<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>


When I fill in both forms, only the parameter from form2 is passed to the url, like page.php?var2=2, var1 is not included.

#2 shocker-z

shocker-z
  • Members
  • PipPipPip
  • Advanced Member
  • 864 posts
  • LocationNottingham

Posted 07 September 2006 - 10:33 AM

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??


<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>

www: www.ukchat.ws | irc: irc.ukchat.ws chan: #blufudge

#3 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 07 September 2006 - 10:46 AM

I have no idea why there's two <form> elements here.

bskauge, why do you think you have a need for two seperate forms?

Regards
Rich
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users