Sunday, 30 June 2013

Insert Coding using mysql



Insert Coding Using Mqsql :


This insert coding is used to  insert the values into the database using mysql.. This will be very usefull for the beginners who is learning PHP....


<?php 
if(isset($_POST['submit']))
{
    $varname1=$_POST['fieldname1']; //field name in the form
    $varname2=$_POST['fieldname2'];
    $varname3=$_POST['fieldname3'];
    //insert coding
    $insert=mysql_query("insert into tablename(fieldname1 in database,fieldname2,fieldname3) values ('$varname1','$varname2','$varname3')") or mysql_error(); 
   //field name in the Database
    if($insert)
    {
        echo "Inserted";
    }
}
?>