bskauge Posted September 7, 2006 Share Posted September 7, 2006 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. Quote Link to comment Share on other sites More sharing options...
shocker-z Posted September 7, 2006 Share Posted September 7, 2006 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] Quote Link to comment Share on other sites More sharing options...
HuggieBear Posted September 7, 2006 Share Posted September 7, 2006 I have no idea why there's two <form> elements here.bskauge, why do you think you have a need for two seperate forms?RegardsRich Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.