Hi,
I have an HTML and a PHP script inserting data into DB.
My problem is when i submit the form, one of the arrays cannot be posted to my PHP Script.
The first SELECT-OPTION Values (mail_select[]) are being posted correctly, however the second SELECT-OPTION Values (OS[]) are not. It brings empty value at all.
If i put OS[] SELECT TAG to first place, -i mean put it before mail_select[] SELECT TAG-, this time mail_select[] brings nothing. And OS[] is being posted correctly.
What could the possible problems be?
Here is the HTML:
bla..bla..
<html>
<form id="SK" action="post.php" method="POST">
<tr>
<td>
<?php
$conn = getConn();
mysql_select_db(getDBName(),$conn);
$query = "select MEMBERS,NAME from mail;";
$result = mysql_query($query,$conn);
echo "<form>";
echo "<select name=\"mail_select[]\" id=\"mail_select[]\" multiple=\"multiple\">";
while($row = mysql_fetch_array($result)) {
$NAME = $row['NAME '];
$MEMBERS = $row['MEMBERS'];
echo "<option value='$MEMBERS'>$NAME</option>";
}
echo "</select></form>";
mysql_close($conn);
?>
</td>
</tr>
<tr><td>
<?php
$conn = getConn();
mysql_select_db(getDBName(),$conn);
$query = "select mark from olsystem;";
$result = mysql_query($query,$conn);
echo "<form style=\"margin:20px 0\">";
echo "<select name=\"OS[]\" id=\"OS[]\" multiple=\"multiple\">";
while($row = mysql_fetch_array($result)) {
$isim = $row['mark'];
echo "<option value='$mark'>$mark</option>";
}
echo "</select></form>";
mysql_close($conn);
?>
</td>
</tr>
<tr height="40"><td width="170"><div class="rowElem"><input type="submit" value="GO!" /><input type="reset" value="Clear" /></div></td></tr>
</form>
</html>
Here is my PHP script:
<?php
include("DB.php");
if(isset($_POST['OS'])){
$OS = implode(",",$_POST['OS']);
$mail_select = implode(",",$_POST['mail_select']);
register($OS,$mail_select);
}
function register($OS,$mail_select)
{
$conn = getConn();
mysql_select_db(getDBName(),$conn);
$query ="insert into outage(OS,mail_select) values ('$OS','$mail_select')";
mysql_query($query,$conn);
if(mysql_affected_rows()>0){
BLA BLA
} else {
}
mysql_close($conn);
}
?>