Solution 1 :

<form class="form-area contact-form text-right" action="mail.php" method="post">
    <div class="row">   
        <div class="col-lg-6 form-group">
            <input name="name" id="name"  placeholder="Enter your name" class="common-input mb-20 form-control"  type="text">
            <input name="email" id="email" placeholder="Enter email address"   class="common-input mb-20 form-control"  type="email">
            <input name="sub" id="sub" placeholder="Enter subject"  class="common-input mb-20 form-control"  type="text">
        </div>
        <div class="col-lg-6 form-group">
            <textarea class="common-textarea form-control" name="desc" id="desc" placeholder="Enter Messege" ></textarea>               
        </div>
        <div class="col-lg-12">
            <button class="genric-btn primary" value="submit" id="submit" name="submit" style="float: right;">Send Message</button>                                         
        </div>
    </div>

More Details view this link VIEW FULL CODE

Problem :

I’m trying to check if the form has been submitted. If I press the submit button, the success message will appear but when I check my mailbox I don’t see any message. I’m using WampServer. I followed a YouTube tutorial where the guy has the exact same code but for some reason, it doesn’t work for me.

<form action="contact.php" method="post" id="myForm">
  <div class="md-form">
    <i class="fas fa-user prefix grey-text"></i>
    <input type="text" required name="name" id="form_name" class="form-control" />
    <label for="form_name">Your name</label>
  </div>

  <div class="md-form">
    <i class="fas fa-envelope prefix grey-text"></i>
    <input type="email" required name="email" id="form_email" class="form-control" />
    <label for="form_email">Your email</label>
  </div>

  <div class="md-form">
    <i class="fas fa-tag prefix grey-text"></i>
    <input type="text" name="subject" required id="form-Subject" class="form-control" />
    <label for="form_subject">Subject</label>
  </div>
  <div class="md-form">
    <i class="fas fa-pencil-alt prefix grey-text"></i>
    <textarea id="form_text" name="message" class="form-control md-textarea" rows="3"></textarea>
    <label for="form_text">Your message</label>
  </div>

  <div class="text-center mt-4">
    <button class="btn contact-button text-white" type="submit" name="submit">Submit</button>
  </div>
  <div id="success_message" class="text-dark text-center"></div>
</form>

<?php
if(isset($_POST['submit']))
{

    $name = $_POST['name'];
    $subject = $_POST['subject'];
    $mailFrom = $_POST['email'];
    $message = $_POST['message'];

    $mailTo = "[email protected]";
    $headers = "From: ".$mailFrom;
    $txt = "You have recieved an e-mail from ".$name.".nn".$message;
 
    mail($mailFrom, $subject, $txt, $headers);
    header("Location: index.php?mailsend");
    
}

?>

Comments

Comment posted by Ebrahim Mohammed

Make sure you actually configured your wamp server to send emails.

Comment posted by error handling

…and activate the

By