index.php

 avatar
unknown
php
5 months ago
1.4 kB
2
Indexable
<?php

    require 'db.php';

    if($_SERVER["REQUEST_METHOD"]== "POST"){

        $First_Name = $_POST['First_Name'] ?? '';
        $Last_Name = $_POST['Last_Name'] ?? '';
        $Age = $_POST['Age'] ?? '';
        $Address = $_POST['Address'] ?? '';

        $sql = "INSERT INTO bsit (First_Name, Last_Name, Age, Address) VALUES('$First_Name', '$Last_Name', '$Age', '$Address')";

        if($conn->query($sql) == TRUE){
            echo "<script> alert ('DATA INSERTED SUCCESFULLY') </script>";
        } else {
            echo "Error: " . $sql . "<br>" . $conn->error;
        }
    }


?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Attendance System</title>
</head>
<body>
    <form action = "index.php" method = "post">
        
        <label for = "First_Name">First Name</label>
        <input type="text" name = "First_Name"> <br>

        <label for = "Last_Name">Last Name</label>
        <input type="text" name = "Last_Name"> <br>

        <label for = "Age">Age</label>
        <input type="text" name = "Age"> <br>

        <label for = "Address">Address</label>
        <input type="text" name = "Address"> <br>

        <input type="submit" value = "Enter">
        <form action = "login.php"><input type="button" value="Log in"></form>
    </form>
</body>
</html>
Editor is loading...
Leave a Comment