PHP contact form email being received with no sender and email is not being populated in the body -


i able receive email information except email address entered in form, , when receive email, "no sender" instead of person's name. new php , have done several google searches can't figure out doing wrong. please help. thanks

this html:

<?php include("parts/doctype.php"); ?> 

<?php include("parts/header.php"); ?>     <div class="page-wrap">      <?php include("parts/nav.php"); ?>            <div class="page-grid">              <h1 class="site-section-title">contact us</h1>              <div class="content-area">                  <form action="send-mail.php" method="post">                      <div class="contactname">                         <h1 class="heading name">name</h1>                         <label for="first-name" class="first_name">first name</label>                         <input type="text" id="first_name" name="first_name"  placeholder="jane" autofocus required>                         <label for="last_name" class="last_name">last name</label>                         <input type="text" id="last_name" name="last_name" placeholder="doe" required>                     </div> <!-- end name -->                      <div class="number">                         <h1 class="heading">phone number</h1>                         <label for="number" class="phone">phone number</label>                         <input type="tel" id="number" pattern="[0-9]{10}" name="sender_phone" placeholder="(###)-###-####">                     </div> <!-- end number -->                      <div class="email">                         <h1 class="heading">email address</h1>                         <label for="email" class="emaillabel">email</label>                         <input type="email" name="sender_email" placeholder="janedoe@gmail.com" required>                     </div>                      <div class="message">                         <h1 class="heading">message</h1>                         <label for="message"></label>                         <textarea name="sender_message" id="message" cols="30" rows="10" spellcheck="true" required> </textarea>                     </div>                      <button id="submit" class="send">send</button>                  </form>              </div> <!-- end content area -->          </div> <!-- end grid -->      </div> <!-- end page wrap --> 

and php:

<?php $mail_to = 'removed address know goes here'; // specify email here  // assigning data $_post array variables $first_name = $_post['first_name']; $last_name = $_post['last_name']; $mail_from = $_post['sender_email']; $phone = $_post['sender_phone']; $message = $_post['sender_message'];  // construct email subject $subject = 'its time cupcake message visitor ' . $first_name;  // construct email body $body_message = 'from: ' . $first_name . $last_name . "\r\n"; $body_message .= 'e-mail: ' . $mail_from . "\r\n"; $body_message .= 'phone: ' . $phone . "\r\n";   $body_message .= 'message: ' . $message;  // construct email headers $headers = 'from: ' . $first_name . "\r\n";  $headers .= 'reply-to: ' . $mail_from . "\r\n";  $mail_sent = mail($mail_to, $subject, $body_message, $headers);   if ($mail_sent == true){ ?>     <script language="javascript" type="text/javascript">     alert('thank message. should message require responce shortly.');     window.location = 'contactus.php';     </script> <?php } else { ?> <script language="javascript" type="text/javascript">     alert('message not sent. please, try message again. should still not work please contact use through facebook or twitter both links located on our home page.');     window.location = 'index.php'; </script> <?php } ?> 

your label should match input id "first-name" , "first_name" won't match. here link:http://www.w3schools.com/tags/att_label_for.asp

other looks pretty good. if not working post try using form method. easier debug because name value pairs passed on url , can @ least verify php routine sent values correctly. if looks try setting break point in php , stepping through it.

hope helps!


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -