/** * Handle the Contact page form submission and email it to the site admin. */ function hc_handle_contact_submit() { if ( ! isset( $_POST['hc_contact_nonce'] ) || ! wp_verify_nonce( $_POST['hc_contact_nonce'], 'hc_contact_submit' ) ) { wp_safe_redirect( add_query_arg( 'contact', 'error', home_url( '/contact/' ) ) ); exit; } // Honeypot field: real users never fill this in. if ( ! empty( $_POST['hc_website'] ) ) { wp_safe_redirect( add_query_arg( 'contact', 'success', home_url( '/contact/' ) ) ); exit; } $name = isset( $_POST['name'] ) ? sanitize_text_field( wp_unslash( $_POST['name'] ) ) : ''; $email = isset( $_POST['email'] ) ? sanitize_email( wp_unslash( $_POST['email'] ) ) : ''; $message = isset( $_POST['message'] ) ? sanitize_textarea_field( wp_unslash( $_POST['message'] ) ) : ''; if ( empty( $name ) || empty( $message ) || ! is_email( $email ) ) { wp_safe_redirect( add_query_arg( 'contact', 'error', home_url( '/contact/' ) ) ); exit; } $to = get_option( 'admin_email' ); $subject = sprintf( '[Health Calculators] New contact message from %s', $name ); $body = "You have a new message from the Health Calculators contact form.\n\n" . "Name: {$name}\n" . "Email: {$email}\n\n" . "Message:\n{$message}\n"; $headers = array( 'Content-Type: text/plain; charset=UTF-8', "Reply-To: {$name} <{$email}>" ); $sent = wp_mail( $to, $subject, $body, $headers ); wp_safe_redirect( add_query_arg( 'contact', $sent ? 'success' : 'error', home_url( '/contact/' ) ) ); exit; } add_action( 'admin_post_hc_contact_submit', 'hc_handle_contact_submit' ); add_action( 'admin_post_nopriv_hc_contact_submit', 'hc_handle_contact_submit' ); Resources - Health & Fitness Articles | Health Calculators

Resources

Guides and articles to help you get more out of our health calculators

Blood Pressure Readings: A Complete Guide to Your Numbers

Understanding your blood pressure readings is one of the simplest things you can do to stay ahead of your cardiovascular health. Every time a nurse or a home…

Read article →

How Much Sleep Do You Need? The Science of Sleep Explained

How much sleep do you need to actually feel rested? Sleep advice is everywhere, but a lot of it boils down to one oversimplified number: eight hours. The…

Read article →

How to Calculate Your Macros for Weight Loss

Counting calories gets you halfway to your goals. Counting macros – protein, carbohydrates, and fat – gets you the rest of the way, because where your calories come…

Read article →

TDEE vs BMR: What’s the Difference and Why It Matters

If you’ve spent any time researching calorie needs, you’ve probably run into two acronyms: BMR and TDEE. They’re related but not interchangeable, and mixing them up is one…

Read article →

Understanding Your BMI: What the Numbers Really Mean

Body Mass Index (BMI) is one of the most widely used health screening tools in the world, but it’s also one of the most misunderstood. If you’ve ever…

Read article →

Free BMI Calculator: Calculate Your Body Mass Index for Optimal Health & Fitness

Read article →

Explore powerful 40+ advanced ‘fitness and health calculators’ designed to boost your wellness journey

Unlock Your Potential with Fitness and Health Calculators Fitness and Health Calculators are your ultimate allies in taking control of your wellness journey. In a world full of…

Read article →

Explore Our Calculators

Put what you learn into practice with our free health, fitness, and nutrition calculators.