aebstract Posted January 17, 2008 Share Posted January 17, 2008 Okay, sorry I keep having these issues. I think my whole drop down code is pretty messed up right now. So basically I should be able to login with this script, which is pulling the plant locations and then checking with what password they put in. I don't think my drop down is passing the information through when you hit submit. It needs to let me know what id is being chosen from the drop down and then I am going to compare that to that plants id/password in the database. mysql_connect("localhost","berryequipment","gU8Kso8Y") or die(mysql_error()); mysql_select_db("berryequipment_net"); $result = mysql_query("SELECT * FROM plants ORDER BY plantloc ASC") or DIE(mysql_error()); $options=""; while ($r=mysql_fetch_array($result)) { $id=$r["id"]; $plantloc=$r["plantloc"]; $options .= "<OPTION VALUE=\"$id\">".$plantloc; } ?> <form action="account.php" method="post"> plant loc<br /> <SELECT NAME=dropdown> <OPTION VALUE=0> <?=$options?> </SELECT> Quote Link to comment https://forums.phpfreaks.com/topic/86534-form-passing-variable/ Share on other sites More sharing options...
yaz Posted January 18, 2008 Share Posted January 18, 2008 I think some stuff is missing, or maybe you forgot? I added in red, what I thought could be wrong, or causing it not to work... <? while ($r=mysql_fetch_array($result)) { $id=$r["id"]; $plantloc=$r["plantloc"]; $options .= "<OPTION VALUE=\"$id\">".$plantloc."</option>"; } ?> <form action="account.php" method="post"><? while ($r=mysql_fetch_array($result)) { plant loc<br /> <SELECT NAME="dropdown"> <OPTION VALUE="0"> <?=$options?> </SELECT> <input type="submit" name="button" id="button" value="Submit" /> </form> If you want to test if the form is returning anything, just do at the top of the page: if($_POST['button']) { var_dump($_POST); } Quote Link to comment https://forums.phpfreaks.com/topic/86534-form-passing-variable/#findComment-442473 Share on other sites More sharing options...
rameshfaj Posted January 18, 2008 Share Posted January 18, 2008 Yes you need to include the selection field inside the form if you want its value to be posted to another page. Quote Link to comment https://forums.phpfreaks.com/topic/86534-form-passing-variable/#findComment-442530 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.