You are on page 1of 4

Name: Syed Mohamid Raza Nadvi

REG# Bcs221098
Section-2
DB-Lab
CODE :
<!DOCTYPE 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>TASK</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f2f2f2;
margin: 0;
padding: 20px;
}

h1 {
color: #333333;
}

form {
margin-top: 20px;
}

label {
display: block;
margin-bottom: 5px;
font-weight: bold;
}
input[type="text"] {
width: 100%;
padding: 8px;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
margin-bottom: 10px;
}

input[type="submit"] {
background-color: #4CAF50;
color: white;
padding: 10px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
}

input[type="submit"]:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<h1>EMPLOYEE INFORMATION</h1>
<form action="submit.php" method="POST">
<label for="name">Fullname:</label>
<input type="text" id="Name" name="name">
<br>
<label for="email">Email:</label>
<input type="text" id="Email" name="email">
<br>
<label for="address">Address:</label>
<input type="text" id="Address" name="address">
<br>
<input type="submit" value="Submit">
</form>

</body>
</html>
PHP
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "Employee";

// Create a connection
$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}

// Prepare and bind the form data


$name = $_POST['Name'];
$email = $_POST['Email'];
$address = $_POST['Address'];

$stmt = $conn->prepare("INSERT INTO employee_info (Name, Email, Address) VALUES (?, ?, ?)");
$stmt->bind_param("sss", $name, $email, $address);

$stmt->close();

// Close the database connection


$conn->close();

echo "Data submitted successfully!";


?>

Output:

You might also like