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 Link to comment https://forums.phpfreaks.com/topic/128189-problem-with-a-form-not-sending-where-its-ment-to/ 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.. Link to comment https://forums.phpfreaks.com/topic/128189-problem-with-a-form-not-sending-where-its-ment-to/#findComment-663924 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. Link to comment https://forums.phpfreaks.com/topic/128189-problem-with-a-form-not-sending-where-its-ment-to/#findComment-663933 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 Link to comment https://forums.phpfreaks.com/topic/128189-problem-with-a-form-not-sending-where-its-ment-to/#findComment-663944 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 Link to comment https://forums.phpfreaks.com/topic/128189-problem-with-a-form-not-sending-where-its-ment-to/#findComment-663950 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.