How can I send an email to myself when someone has submitted a form?
To send an email to yourself when someone has submitted a form, you can use the PHP mail() function to send an email notification. You can add this function to the form submission processing code, so that an email is triggered whenever the form is submitted.
// Process form submission
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Your form processing code here
// Send email notification to yourself
$to = "your-email@example.com";
$subject = "Form submission received";
$message = "A form has been submitted on your website.";
$headers = "From: your-email@example.com";
mail($to, $subject, $message, $headers);
}
Keywords
Related Questions
- How can PHP be used to efficiently store and retrieve multiple permissions for a user in a database?
- What are the potential pitfalls of using GROUP_CONCAT() in MySQL when creating JSON output in PHP?
- How can one optimize the SQL queries in PHP code to improve performance when filtering data based on user input?