Professional Documents
Culture Documents
PHP
PHP
php
// Check if form is submitted
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Get the input values
$name = $_POST["name"];
$email = $_POST["email"];
$message = $_POST["message"];
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Contact Form</title>
<style>
/* Add your CSS styles here */
</style>
</head>
<body>
<div class="container">
<h2>Contact Me</h2>
<?php if(isset($error)) { ?>
<div class="error"><?php echo $error; ?></div>
<?php } ?>
<?php if(isset($success)) { ?>
<div class="success"><?php echo $success; ?></div>
<?php } ?>
<form method="post" action="<?php echo
htmlspecialchars($_SERVER["PHP_SELF"]); ?>">
<label for="name">Name:</label>
<input type="text" name="name" id="name" required>
<label for="email">Email:</label>
<input type="email" name="email" id="email" required>
<label for="message">Message:</label>
<textarea name="message" id="message" required></textarea>
<button type="submit">Send Message</button>
</form>
</div>
</body>
</html>