-1

I've searched around SO and I can't figure out what is going on here. I have an HTML form that I'm sending through PHP backend. The submissions were going through, but then I made some changes and now I can't figure out what went wrong. It's on a custom template I made on a WordPress site, but it's just a straight html form converted to a .php file basically, and then a mail.php file that has the php mail function and everything. It's hosted on GoDaddy's servers so I can't imagine it's a server issue, especially since they were going through before. Maybe it's a simple syntax error, so here's my code:

<form name="quote" id="price-quote" action="/wp-content/themes/Divi-child/mail.php" method="post">
    <div class="container">
         <div class="row">
           <div class="col-sm-6"> 
                <div class="form-group">
                    <label for="text_id" class="control-label">First Name</label>
                    <input type="text" class="form-control" id="text_id" name="name">
                </div>
                <div class="form-group">
                    <label for="text_id" class="control-label">Last Name</label>
                    <input type="text" class="form-control" id="text_id" name="last-name">
                </div>
                <div class="form-group">
                    <label for="email_id" class="control-label">Email</label>
                    <input type="email" class="form-control" id="email_id" name="email">
                 </div>
                 <div class="form-group">
                    <label for="phone" class="control-label">Phone Number</label>
                    <input type="text" class="form-control" id="phone_id" name="phone">
                </div>
                <div class="form-group">
                    <label for="phone" class="control-label">Phone Number 2</label>
                    <input type="text" class="form-control" id="phone_id_2" name="phone2">
                </div>
              </div>
                <div class="col-sm-6">
                  <div class="form-group">
                    <label for="address_line_1" class="control-label">Address Line 1</label>
                    <input type="text" class="form-control" id="address_id" name="address">
                </div>
                <div class="form-group">
                    <label for="address_line_2" class="control-label">Address Line 2</label>
                    <input type="text" class="form-control" id="address_id_2" name="address2">
                </div>
                <div class="form-group">
                    <label for="city" class="control-label">City</label>
                    <input type="text" class="form-control" id="city_id" name="city">
                </div>
                <div class="form-group">
                    <label for="state" class="control-label">State</label>
                    <input type="text" class="form-control" id="state_id" name="state">
                </div>
                <div class="form-group">
                    <label for="zipcode" class="control-label">Zip Code</label>
                    <input type="text" class="form-control" id="zip_id" name="zip">
           </div>
         </div>
      </div>
    </div>
</form>

PHP

<?php 
$name = $_POST['name'];
$name2 = $_POST['last-name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$phone2 = $_POST['phone2']
$address = $_POST['address'];
$address2 = $_POST['address2'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$email_subject = "Price Quote";
$email_body="From: $name \n From: $name2 \n Email: $email \n Phone Number 1: $phone \n Phone Number 2: $phone2 \n Address: $address \n Address Line 2: $address2 \n City: $city \n  State: $state \n Zip Code: $zip";
$to = "colten@kitemedia.com";
$headers = "From: $email";
mail($to, $email_subject, $email_body, $headers);
header("Location: http//:example.com");
?>

I did find this very thorough guide on Stack Overflow to figuring out PHP Mail errors but I still couldn't find a solution. I'm completely lost at what this could be, any help is appreciated.

Note: the PHP code is from my mail.php file, and it's in the directory /wp-content/themes/Divi-child.

Community
  • 1
  • 1
Coltvant
  • 304
  • 2
  • 18

1 Answers1

1

You are missing a semi-colon ; after this line:

$phone2 = $_POST['phone2']

Please read How to get useful error messages in PHP? to get you started with error reporting. After you have enable error reporting in your script you will get a Parse error: syntax error, unexpected '$address' (T_VARIABLE) error, which you can debug using this guide.

Community
  • 1
  • 1
Tom Udding
  • 2,264
  • 3
  • 20
  • 30
  • Ha, you've got to be kidding me, a semi colon. Thanks so much for catching that, I can't believe I overlooked that so many times. I'll look at that guide, I'm new to PHP so I appreciate the resources. That will help a lot with debugging. – Coltvant Apr 13 '17 at 16:04