Jump to content

$_POST Array not being passed


suttercain

Recommended Posts

Hi guys,

 

I have two select menus using javascript and the first one is populated via a mysql query. The idea is simple, select items from the left menu and add them to the right menu. I then want to inser the information from the right select menu into the database. The problem I am having is that the information that I am adding to the right select menu (or even the left menu for this matter) is not being sent to the $_POST variable.

 

<body>

<?php
if (isset($_POST['submit'])) {
echo $_POST['sel2'];
print_r($_POST);
}


$sql = mysql_query("SELECT * FROM characters ORDER BY name");

?>
<form action="<?php $_SERVER['PHP_SELF']; ?>" method="post">
<table border="0">
<tr>
	<td>
		<select name="sel1" size="10" multiple="multiple">
            <?php
		while ($row = mysql_fetch_array($sql)) {
		echo "<option value='".$row['character_id']."'>".$row['name']. " - ".$row['alter_ego']. "</option>";
		}
		?>
		</select>
	</td>
	<td align="center" valign="middle">
		<input type="button" value="-->"
		 onclick="moveOptions(this.form.sel1, this.form.sel2);" /><br />
		<input type="button" value="<--"
		 onclick="moveOptions(this.form.sel2, this.form.sel1);" />
	</td>
	<td>
		<select name="sel2" size="10" multiple="multiple">

		</select>
	</td>
</tr>
</table>
<input type="submit" name="submit">
</form>
<?php

?>

</body>

 

I can rationalize why the content from the second select menu, sel2, is not being passed, because there are no values. But shouldn't the first select menu be passed?

 

When I submit the form and print_r($_POST) I get:

Array ( [submit] => Submit Query )

 

Any help would be appreciated..

 

Thanks.

 

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.