Jump to content

php form email


jharrisonweb

Recommended Posts

Hey all

I'm having trouble getting a form to email me when it's submitted. the url is HarrisonAndSonsConstruction.net/contact.html

I have a form in the footer that works and I copied most of the code, changing names. I'm not sure why its not working. It will send me an email, but it seems like the variables aren't being loaded, I'm just getting a blank email.

 

This is the form html

 

<form action="contact.php" id='contContact' class='container'>
<section class='col-1-3 module'>
<input type="text" name="conName" id="conName" placeholder="Name:">
<input type="email" name="conEmail" id="conEmail" placeholder="Email:">
<input type="phone" name="conPhone" id="conPhone" placeholder="Phone:">
<br><input name="Submit" type="submit" value="Send" id="submit">
</section>
<section class='col-1-3 module'>
<textarea name="conEssay" id="conEssay" placeholder="Message:"></textarea>
</section>
<section class='col-1-3 last module'>
<h3>Address</h3>
<h5>Oswego, IL</h5>
<h3>Phone</h3>
<h5>(331)454-6044</h5>
<h3>Email</h3>
</section>
</form>
 
And the php
 
<?php
  $conName_field = $_POST['conName'];
  $conEmail_field = $_POST['conEmail'];
  $conPhone_field = $_POST['conPhone'];
  $conMessage = $_POST['#conEssay'];
    $email_to = '[email protected]';
    $subject = 'Message from OswegoBasementRemodeling.com '.$conName_field;
$Header = "MIME-Version: 1.0\r\n"; 
    $Header .= "Content-type: text/html; charset=iso-8859-1\r\n"; 
    $header .= 'From: '.$conEmail_field."\r\n";
    $header .= 'Reply-To: '.$conEmail_field."\r\n";
    $body = 'From: '.$conName_field."\n";
    $body .= 'Email: '.$conEmail_field."\n";
    $body .= 'Phone: '.$conPhone_field."\n";
    $body .= 'Message: '.$conMessage."\n";
 
    
    $mail_status = mail($email_to, $subject, $body, $headers);
    
    
  if ($mail_status) { ?>
      <script language="javascript" type="text/javascript">
          alert('Thank you for the message. We will contact you shortly.');
          window.location = 'index.html';
      </script>
  <?php
  }
  else { ?>
      <script language="javascript" type="text/javascript">
          // Print a message
          alert('Message failed. Please, send an email to [email protected]');
          // Redirect to some page of the site. You can also specify full URL, e.g. http://template-help.com
          window.location = 'index.html';
      </script>
  <?php
  }
?>
 
 

 Any help would be much appreciated

Link to comment
https://forums.phpfreaks.com/topic/286335-php-form-email/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.