Jump to content

form passing variable


aebstract

Recommended Posts

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>

Link to comment
https://forums.phpfreaks.com/topic/86534-form-passing-variable/
Share on other sites

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

}

Link to comment
https://forums.phpfreaks.com/topic/86534-form-passing-variable/#findComment-442473
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.