Jump to content

php form email


jharrisonweb
Go to solution Solved by WebStyles,

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>
<h5>RndyHarrison@gmail.com</h5>
</section>
</form>
 
And the php
 
<?php
  $conName_field = $_POST['conName'];
  $conEmail_field = $_POST['conEmail'];
  $conPhone_field = $_POST['conPhone'];
  $conMessage = $_POST['#conEssay'];
    $email_to = 'jharrisonweb@gmail.com';
    $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 RndyHarrison@gmail.com');
          // 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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.