0
</script>
</head><body>
<form action="naw1.php"
onsubmit="return validate_form(this)"
method="post">
contactgroups<br><br>
<?php
$instance=1;
//$conn=new mysqli('192.168.1.50','root','adm1ns','nagios');
$db=new mysqli('192.168.1.50','root','adm1ns','aptus') or die ('Cannot connect to MySQL server');
$sql="select alias from aptus_contactgroups where instance_id=?";
$stmt=$db->stmt_init();
$stmt->prepare($sql);
$stmt->bind_param("i",$instance);
$stmt->execute();
$stmt->bind_result($time);
echo "<select multiple=\"contact_groups[]\" >";
while($stmt->fetch())
{
echo "<option value=\"".$time."\">".$time."</option>";

}


<input type="submit" value="Submit">
 <?php
$cg=count($_POST['contact_groups']);
for($i=0;$i<$cg;$i++)
{
echo $_POST['contact_groups'][$i];
}
?>

In this code, i am getting error as undefined index in contact_groups. i cant find out where is the problem. pls help

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by somedude3488
0

you have your select name in the multiple attrib.

that needs to be its own attribute <select name="contact_groups[]" multiple="multiple"> also, undefined index is a warning which can be turned off. its not an error.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.