Basic code for PHP contact form
<form action="send_form_email.php" method="post">
<label for="name">Name:</label>
<input type="text" id="name" name="name"><br>
<label for="email">Email:</label>
<input type="email" id="email" name="email"><br>
<label for="message">Message:</label>
<textarea id="message" name="message"></textarea><br>
<input type="submit" value="Submit">
</form>
You would also need to create a separate PHP file, “send_form_email.php”, to handle the form submission and send the email:
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$to = "your@email.com";
$subject = "Contact Form Submission";
$headers = "From: $email";
mail($to, $subject, $message, $headers);
?>
Leave a Reply