<?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password="123456"; // Mysql password
$db_name="mydatabase"; // Database name
$tbl_name="drug"; // Table name
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
for ($l = 1; $l <= 5; $l++) {
// Get values from form
$save=$_POST['.$name_txt_box[$l].'];
// Insert data into mysql
$sql="INSERT INTO $tbl_name(id)VALUES('$save')";
$result=mysql_query($sql);
}
// if successfully insert data into database, displays message "Successful".
if($result){
echo "Successful";
echo "<BR>";
echo "<a href='checkboxs.php'>Back to main page</a>";
}
else {
echo "ERROR";
}
?>
<?php
// close connection
mysql_close();
?>