EXP NO10

 <!DOCTYPE html>

#insert.html
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <form action="insert.php" method="post">
        <label for="id">ID:</label>
        <input type=" text" id="id" name="id"><br><br>
        <label for="Name">Name:</label>
        <input type=" text" id="name" name="name"><br><br>
        <label for="Email">Email:</label>
        <input type=" email" id="email" name="email"><br><br>
        <input type="submit" value="submit">
    </form>
   
</body>
</html>

-------------------------------------------------------------------
#insert.php
<?php
$a = $_POST['id'];
$b = $_POST['name'];
$c = $_POST['email'];



$servername = "localhost";
$username = "root";
$password = "";
$dbname = "csedkte";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
  die("Connection failed: " . $conn->connect_error);
}

$sql = "INSERT INTO students
VALUES ('$a', '$b', '$c')";




if ($conn->query($sql) === TRUE) {
  echo "New record created successfully";
} else {
  echo "Error: " . $sql . "<br>" . $conn->error;
}

$conn->close();
?>
---------------------------------------------------------------------
#delete.php
<?php
$a = $_POST['id'];

$servername = "localhost";
$username = "root";
$password = "";
$dbname = "csedkte";


// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
  die("Connection failed: " . $conn->connect_error);
}

// sql to delete a record
$sql = "DELETE FROM students WHERE id=111";

if ($conn->query($sql) === TRUE) {
  echo "Record deleted successfully";
} else {
  echo "Error deleting record: " . $conn->error;
}

$conn->close();
?>

Post a Comment

0 Comments