Modern Web Applications
Modern Web Applications
Date : 09/11/2023
Submitted By :
Name : SUBHRANSU SEKHAR ROUT
Reg.No : 20BBS0176
SLOT : L53+L54
SUBMITTED TO -: SIVAKUMAR V
LAB DA : 04
Config.php
Create.php
<?php include("config.php");
mysqli_close($connection);
index.php
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<header>
<h1>PHP & MySQL 20BBS0176</h1>
</header>
</html>
Insert.php
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
</html>
<?php include("config.php");
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$id = $_POST["id"];
$username = $_POST["username"];
$email = $_POST["email"];
mysqli_close($connection);
?>
<?php
include("config.php");
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$id = $_POST["id"];
$newEmail = $_POST["newEmail"];
mysqli_close($connection);
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<body>
<main>
<div class="content">
<h2>Update Employee Data</h2>
<form method="post">
<label for="id">User ID:</label>
<input type="text" name="id" required><br>
<label for="newEmail">New Email:</label>
<input type="email" name="newEmail" required><br>
<input type="submit" value="Update">
</form>
</div>
</main>
</body>
</html>
Delete.php
<?php include("config.php");
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$id = $_POST["id"];
$sql = "DELETE FROM employee WHERE id='$id'"; if
(mysqli_query($connection, $sql)) {
echo "Data deleted successfully";
} else {
echo "Error deleting data: " . mysqli_error($connection);
mysqli_close($connection);
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<main>
<div class="content">
<h2>Delete Data</h2>
<form method="post">
<label for="id">User ID:</label>
<input type="text" name="id" required><br>
<input type="submit" value="Delete">
</form>
</div>
</main>
</body>
</html>
View.php
<?php include("config.php");
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<main>
<div class="content">
<h2>View Employee Data</h2>
<table>
<tr>
<th>ID</th>
<th>Username</th>
<th>Email</th>
</tr>
<?php
while ($row = mysqli_fetch_assoc($result)) { echo "<tr><td>" .
$row["id"] . "</td><td>" .
$row["username"] . "</td><td>" . $row["email"] . "</td></tr>";
}
?>
</table>
</div>
</main>
</body>
</html>