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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.