html - header redirect on php form not working -


i'm new php , needed form. had working earlier it's deciding not work. appreciated.

php section header going page in same directory

<!-- php form e-mailer -->          <?php     if (isset($_post["submit"])) {         $name = $_post['name'];         $phone = $_post['phone'];         $message = $_post['message'];         $from = 'very local';         $to = 'myemail@gmail.com'; // business email address         $subject = 'message local';          $body ="from: $name\n number: $phone\n message:\n $message";         // check if name has been entered         if (!$_post['name']) {             $errname = 'please enter name';         }          // check if email has been entered , valid         if (!$_post['phone'] || !filter_var($_post['phone'])) {             $errphone = 'please enter valid phone number';         }          //check if message has been entered         if (!$_post['message']) {             $errmessage = 'please enter message';         }  // if there no errors, send email if (!$errname && !$errphone && !$errmessage) {     if (mail ($to, $subject, $body, $from)) {          header("location: success.html");     } else {         header("location: fail.html");     } }     } ?> 

and html within bootstrap.

<!-- form section -->  <div id="callcontain" class="container-fluid">     <div class="container form">         <div class="row">             <div class="col-md-8 col-md-offset-2">                    <form id="contact-form" role="form" method="post" action="index.php">                      <div class="controls">                         <div class="row">                             <div class="col-md-6">                                   <!-- form name -->                                  <div class="form-group">                                     <label for="name" class="control-label">name <small>*</small></label>                                     <input type="text" class="form-control" id="name" required="required" name="name" placeholder="name" value="<?php echo htmlspecialchars($_post['name']); ?>">                                     <?php echo "<p class='text-danger'>$errname</p>";?>                                     <div class="help-block with-errors"></div>                                 </div>                                  <!-- end form name -->                              </div>                               <div class="col-md-6">                                   <!-- form number -->                                  <div class="form-group">                                     <label for="phone" class="control-label">phone number <small>*</small></label>                                     <input type="phone" class="form-control" id="phone" required="required" name="phone" placeholder="phone number" value="<?php echo htmlspecialchars($_post['phone']); ?>">                                     <?php echo "<p class='text-danger'>$errphone</p>";?>                                     <div class="help-block with-errors"></div>                                 </div>                                  <!-- end form number -->                              </div>                          </div>  <!-- end row 1 form -->                            <div class="row">                             <div class="col-md-12">                                   <!-- form message -->                                  <div class="form-group">                                     <label for="message" class="control-label">message</label>                                     <textarea class="form-control" rows="6" name="message"><?php echo htmlspecialchars($_post['message']);?></textarea>                                     <?php echo "<p class='text-danger'>$errmessage</p>";?>                                     <div class="help-block with-errors"></div>                                 </div>                                  <!-- end form message -->                               </div>                               <!-- form submit -->                              <div class="col-md-12 text-center">                                 <input id="submit" name="submit" type="submit" value="send" class="btn btn-success btn-send">                             </div>                              <!-- end form submit -->                           </div>                           <!-- form required -->                          <div class="row">                             <div class="col-md-12 text-center">                                 <p class="text-muted small">* these fields required.</p>                             </div>                             <div class="form-group">                                 <div class="col-sm-12">                                     <?php echo $result; ?>                                 </div>                             </div>                         </div>                   </form> <!-- end form -->                  </div>             </div>         </div>     </div>   </div>  <!-- end form section --> 

form sends fine re-direct isn't working.

thanks in advance.

try putting exit; after header redirect.


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -