troubleshooting Question

Send email using HTML and PHP in separate file

Avatar of Alison Cox
Alison Cox asked on
4 Comments1 Solution524 ViewsLast Modified:
I have this all working (email sends just fine), except that on the HTML page I want the message "Thank you for sending us a message. We will get back to you as soon as possible." to appear on the contact-us.html.   What have I missed?  

<!DOCTYPE html>
<html lang="en">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">

    <header id="header">

    <section id="contact-page">
        <div class="container">
            <div class="center">        
                <h2>Send A Message</h2>
                <p class="lead"></p>
            <div class="row contact-wrap"> 
                <div class="status alert alert-success" style="display: none"></div><div class="content">
                  <form  class="contact-form" name="contact-form" action="sendemail.php"   method="post">
                    <div class="col-sm-5 col-sm-offset-1">
                        <div class="form-group">
                            <label>Name *</label>
                            <input type="text" name="name" class="form-control" required="required">
                        <div class="form-group">
                            <label>Email *</label>
                            <input type="text" name="email" class="form-control" required="required">
                    <div class="col-sm-5">
                        <div class="form-group">
                            <label>Subject *</label>
                            <input type="text" name="subject" class="form-control" required="required">
                        <div class="form-group">
                            <label>Message *</label>
                            <textarea name="message"  required="required" class="form-control" rows="8"></textarea>
                        <div class="form-group">
                            <input type="submit"  class="btn btn-primary btn-lg"  >



$status = array(
		'message'=>'Thank you for sending us a message. We will get back to you as soon as possible. '
  header('Location: contact-us.html','Content-Type: application/json');
    $name = @trim(stripslashes($_POST['name']));
    $email = @trim(stripslashes($_POST['email']));
    $subject = @trim(stripslashes($_POST['subject']));
    $message = @trim(stripslashes($_POST['message']));

    $email_from = $email;
    $email_to = '';

    $body = 'Name: ' . $name . "\n\n" . 'Email: ' . $email . "\n\n" . 'Subject: ' . $subject . "\n\n" . 'Message: ' . $message;

    $success = @mail($email_to, $subject, $body, 'From: <'.$email.'>');
    echo $status;
Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros