INSERT RECORD INTO DATABASE BY PHP IN WEBPAGE

 INSERT RECORD INTO DATABASE BY PHP IN WEBPAGE 

1. INSERT RECORD

(insert.php )

 

<!DOCTYPE html>

<html>

  <body>

          <form method="post" action="insert1.php">

                    Employ ID:<br>

                    <input type="text" name="eid">

                    <br>

                    Employ Name:<br>

                    <input type="text" name="ename">

                    <br>

                    Employ Father Name:<br>

                    <input type="text" name="fname">

                    <br>

                    City name:<br>

                    <input type="text" name="city">

                   

                    <br><br>

                    <input type="submit" name="save" value="submit">

          </form>

  </body>

</html>

(insert1.php)

 

<?php

include_once 'database.php';

if(isset($_POST['save']))

{        

           $eid = $_POST['eid'];

          $ename = $_POST['ename'];

           $fname = $_POST['fname'];

           $city = $_POST['city'];

           

           $sql = "INSERT INTO emp(eid,ename,fname,city)

           VALUES ('$eid','$ename','$fname','$city')";

           if (mysqli_query($con, $sql)) {

                    echo "New record created successfully !";

           } else {

                    echo "Error: " . $sql . "

" . mysqli_error($con);

           }

           mysqli_close($con);

}

?>

<a href="retrieve.php">Employee List</a>



==========================================================  




Post a Comment

0 Comments