Php Bootstrap contact form not working, no email/data posted

I have a form in Bootstrap that's inside a modal. When I click the "Submit" there is seems nothing happen,

I have checked the code for the typo and other errors and it seems nothing wrong with my php code but again every time I fill the form and hit the submit button the page is reloaded but email/data not posted

here is the complete php code :

<?php
if(isset($_POST['Submit'])){
    $to = 'Support@example.com'; // this is your Email address
    $from = $_POST['faq-contact-email'];// this is the sender's Email address
    $first_name = $_POST['faq-contact-firstname'];
    $last_name = $_POST['faq-contact-lastname'];
    $division = $_POST['faq-contact-subject'];
    $subject = $_POST['contact-subject'];
    $themessage = $_POST['faq-contact-msg'];

    $message = 'Support mail from : '.$first_name.' '.$last_name.'<br/>
    To : '.$division.' Division<br/>
    <hr/>
    '.$themessage.'';
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers .= "From: ".$from."\r\n"."X-Mailer: php";
    mail($to,$subject,$message,$headers);


    echo "Support message Sent. Thank you " . $first_name . ", we will contact you shortly.";
} 

?>
<div class="content">
<div class="panel panel-default">
                                    <div class="panel-heading">
                                        <h3 class="panel-title">
                                            <a class="accordion-toggle" data-toggle="collapse" data-parent="#faq4" href="#faq4_q1"><i class="fa fa-envelope-o"></i> Contact Support</a>
                                        </h3>
                                    </div>
                                    <div id="faq4_q1" class="panel-collapse collapse in">
                                        <div class="panel-body">
                                            <form method="post" action="" class="form-horizontal push-10-t" >
                                                <div class="form-group">
                                                    <div class="col-xs-6 col-sm-4">
                                                        <div class="form-material form-material-primary">
                                                            <input class="form-control" type="text" id="faq-contact-firstname" name="faq-contact-firstname" placeholder="Enter your firstname..">
                                                            <label for="faq-contact-firstname">Firstname</label>
                                                        </div>
                                                    </div>
                                                    <div class="col-xs-6 col-sm-4">
                                                        <div class="form-material form-material-primary">
                                                            <input class="form-control" type="text" id="faq-contact-lastname" name="faq-contact-lastname" placeholder="Enter your lastname..">
                                                            <label for="faq-contact-lastname">Lastname</label>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <div class="col-sm-8">
                                                        <div class="form-material form-material-primary input-group">
                                                            <input class="form-control" type="email" id="faq-contact-email" name="faq-contact-email" placeholder="Enter your email..">
                                                            <label for="faq-contact-email">Email</label>
                                                            <span class="input-group-addon"><i class="fa fa-envelope-o"></i></span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <div class="col-sm-4">
                                                        <div class="form-material form-material-primary">
                                                            <select class="form-control" id="faq-contact-subject" name="faq-contact-subject" size="1">
                                                                <option value="1">Tech Support</option>
                                                                <option value="2">Billing</option>

                                                            </select>
                                                            <label for="faq-contact-subject">Where?</label>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="col-xs-6 col-sm-4">                                                        
                                                <div class="form-material form-material-primary">
                                                <input class="form-control" type="text" id="contact-subject" name="contact-subject" placeholder="Enter your subject..">
                                                <label for="contact-subject">Subject</label>                                                        
                                                </div>                                                    
                                                </div>
                                                <div class="form-group">
                                                    <div class="col-xs-12">
                                                        <div class="form-material form-material-primary">
                                                            <textarea class="form-control" id="faq-contact-msg" name="faq-contact-msg" rows="7" placeholder="Enter your message.."></textarea>
                                                            <label for="faq-contact-msg">Message</label>
                                                        </div>
                                                        <div class="help-block text-right">Feel free to use common tags: &lt;blockquote&gt;, &lt;strong&gt;, &lt;em&gt;</div>
                                                    </div>
                                                </div>
                                                <div class="form-group remove-margin-b">
                                                    <div class="col-xs-12">
                                                        <button class="btn btn-sm btn-primary" name="submit" type="submit"><i class="fa fa-send push-5-r"></i> Send Message</button>
                                                    </div>
                                                </div>
                                            </form>
                                        </div>
                                    </div>
                                </div>
</div>

Can anyone please help me what's wrong with my code If someone could help that would be greatly appreciated! Thanks

2 answers

  • answered 2018-05-16 04:37 lopamudra

    Check your first line

    if(isset($_POST['Submit']))     
    

    You have written "Submit" (capital S) ,where the name of your button is "submit" . so make it

    if(isset($_POST['submit']))
    

  • answered 2018-05-16 07:19 duatis

    Ok, I make an answer of my comment.

    if(isset($_POST['Submit'])) 
    

    Change Submit to submit. You can also use

    if(isset($_POST))
    

    instead