DB_name: test
Tablename:option
attribute:name char(5);
index.php
<html> <head> <title>OPTION</title> </head> <body> <form method="post" action="index.php" >
Name :
<select name="nameoption"> <option value="name1">name1</option> <option value="name2">name2</option> <option value="name3">name3</option> <option value="name4">name4</option> </select><br> <input type="submit" name="submit"> </form> </body> </html> <?php
include("database/db_conection.php");
if(isset($_POST['submit']))
{
$name1=$_POST['nameoption'];
$insert_data=("insert into option ('name') VALUE ('$name1')");
if(mysqli_query($dbcon,$insert_data))
{
echo "insert sucess fully";
}
else
{
echo mysqli_errno($dbcon);
}
}
?>
db_connection.php
<?php
try{
$dbcon=mysqli_connect("localhost","root","pass") or die("Could not connected");
mysqli_select_db($dbcon,"test");
}
catch(exception $msg)
{
echo $msg;
}
?>
this program run partially because the out show return value "1064 ".the record was not insert into database