Bootstrap PHP Form Send Email not woking

Hi there I need help on just this one thing then my site is complete.

I have a Bootstrap Contact form inside my modal, but I can’t get the PHP to capture and send the information to my email address.

My Bootstrap Form:

<form class="form-horizontal" role="form" method="POST" action="process.php">
        
        <div class="form-group">
      <label class="control-label col-sm-2" for="fname" style="color:white">Your Full Name:</label>
      <div class="col-sm-10">
        <input type="fname" class="form-control" id="fname" placeholder="Enter your full name...">
      </div>
    </div>
    
    <div class="form-group">
      <label class="control-label col-sm-2" for="email" style="color:white">Your Email:</label>
      <div class="col-sm-10">
        <input type="email" class="form-control" id="email" placeholder="Enter your email...">
      </div>
    </div>
    
    <div class="form-group">
      <label class="control-label col-sm-2" for="message" style="color:white">Your Message:</label>
      <div class="col-sm-10">
        <textarea class="form-control" row="8" placeholder="Enter your message..."></textarea>
      </div>
    </div>
        
</form>

Here is my PHP:

<?php
$fname = $_POST['fname'];
$email = $_POST['email'];
$message = $_POST['message'];
$submit = $_POST['submit'];

if($submit){

$from = 'From: -removed-domain-'."\r\n"; 
$to = 'info@momentdesigns.co.za'; 
$subject = "Message from -removed-domain-";
$body = "".
    "From: ".$fname."\n".
    "E-mail: ".$email."\n".
    "Message: ".$message."\n";

if(mail($to, $subject, $body, $from)){
    echo '<p>Your message has been sent!</p>';
}
else{
    die('<p>Something went wrong, go back and try again!</p>'); 
}
}
?>

Inputs in your form doesn’t have name attributes.

Replace this tag:

<input type="fname" class="form-control" id="fname" placeholder="Enter your full name...">

with this:

<input type="text" name="fname" class="form-control" id="fname" placeholder="Enter your full name...">

and add name to all other inputs and textarea

Also i don’t see submit button in your form, but you check for $_POST[‘submit’] in code

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.