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
https://forums.phpfreaks.com/topic/80316-_post-array-not-being-passed/
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.