We 7
We 7
Mathan Kumar
311522205024
PROGRAM:
SQL:
PHP:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Add and Display Users</title>
</head>
<body>
<form action="" method="post">
<label>Name:</label>
<input type="text" name="name" required>
<label>Address:</label>
<input type="text" name="address" required>
<label>Phone:</label>
<input type="text" name="phone" required>
<label>Email:</label>
<input type="email" name="email" required>
<button type="submit">Submit</button>
</form>
<?php
// connect to the database
$servername = "localhost";
$username = "root";
$password = "mathan@2004";
$dbname = "we";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// sanitize input data
$name = $conn->real_escape_string($_POST['name']);
$address = $conn->real_escape_string($_POST['address']);
$phone = $conn->real_escape_string($_POST['phone']);
$email = $conn->real_escape_string($_POST['email']);
G.Mathan Kumar
311522205024
OUTPUT: