Professional Documents
Culture Documents
Reg# Bcs221098
DB-Lab
Section-2
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$fullName = $_POST['fullname'];
$email = $_POST['email'];
$password = $_POST['password'];
$confirmPassword = $_POST['confirmpassword'];
$errors = array();
if (empty($email)) {
$errors[] = "Email Address is required";
}
if (empty($password)) {
$errors[] = "Password is required";
}
if (empty($confirmPassword)) {
$errors[] = "Confirm Password is required";
}
// Compare passwords
if ($password !== $confirmPassword) {
$errors[] = "Passwords do not match";
}
if (empty($errors)) {
// Registration successful
echo "Registration successful!";
} else {
// Display error messages
foreach ($errors as $error) {
echo $error . "<br>";
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>User Registration</title>
</head>
<body>
<h2>User Registration</h2>
<form method="post" action="">
<label for="fullname">Full Name:</label>
<input type="text" name="fullname" id="fullname" required><br>
<label for="password">Password:</label>
<input type="password" name="password" id="password" required><br>
Output