function save_to_database() { // Insert values from $_POST array $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $email = $_POST['email']; // Insert data to MySQL database $conn = mysqli_connect("localhost", "username", "password", "database_name"); $query = "INSERT INTO users (first_name, last_name, email) VALUES ('$first_name', '$last_name', '$email')"; mysqli_query($conn, $query); } add_action('post_save', 'save_to_database');
function send_email_notification() { // Get values from $_POST array $name = $_POST['name']; $email = $_POST['email']; $message = $_POST['message']; // Send email notification to website owner $to = 'owner@example.com'; $subject = 'New Contact Form Submission'; $body = "Name: $name \n\n Email: $email \n\n Message: $message"; wp_mail($to, $subject, $body); } add_action('post_save', 'send_email_notification');The package/library used in the examples is WordPress, specifically the `wp_mail()` function for sending email notifications. However, the same concept can be applied to other PHP frameworks or libraries that support post save hooks.