ericburnard Posted October 13, 2008 Share Posted October 13, 2008 Hey there. First of here is my problem code ? include ('db.php'); mysql_connect($host,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM departments"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); echo " <form name='dep' action='login2.php?page=6&dep=$department' method='get'> <select name='dep'>"; $i=0; while ($i < $num) { $id=mysql_result($result,$i,"id"); $department=mysql_result($result,$i,"department"); echo " <option value='$department'>$department</option> "; $i++; } ?> </select> <input type="submit" value="Go"> </form> Ass you can see, i am wanting to send my form to 'login2.php?page=6&dep=$department' The problem that im having is that it is only sending the user to 'login2.php?dep=(whatever department they chose)' I have tried allsorts from taking the name='dep' out of the select bit to changing the method of the form to 'post' (usin post will send it to the right page but it wont diplay the value chose in the dropdown box on the page before) Im sure its something really stupid that ive missed or done wrong but its starting to bug me now!!! Any help please Eric x Quote Link to comment Share on other sites More sharing options...
Norsk.Firefox Posted October 13, 2008 Share Posted October 13, 2008 Try to remove the &dep=$department from the action.. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted October 13, 2008 Share Posted October 13, 2008 When you use method="get", the form data replaces anything you have already put after the URL in the action="..." parameter. Just put hidden fields in the form with the page=6&dep=$department values - echo "<input type=\"hidden\" name=\"page\" value=\"6\"> <input type=\"hidden\" name=\"dep\" value=\"$department\">"; Or use the POST method. Quote Link to comment Share on other sites More sharing options...
ericburnard Posted October 13, 2008 Author Share Posted October 13, 2008 When you use method="get", the form data replaces anything you have already put after the URL in the action="..." parameter. Just put hidden fields in the form with the page=6&dep=$department values - echo "<input type=\"hidden\" name=\"page\" value=\"6\"> <input type=\"hidden\" name=\"dep\" value=\"$department\">"; Or use the POST method. Thats worked!! thanks!! Just one more problem has arrisen its now sending to this link http://ericburnard.freehostia.com/login2.php?page=6&dep=&dep=Admin There is one dep to many in the address Quote Link to comment Share on other sites More sharing options...
ericburnard Posted October 13, 2008 Author Share Posted October 13, 2008 ok i have fixed the last problem. I numbered all of the deps that were in the form and then deleted the ones that wernt needed in the address box. Now im having a problem with getting the dep value from the address box even though it worked before!! $depart=$_GET["dep"]; That is what im using which is correct, right? So every time i paste $depart it should display the value from the address box 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.