Когда я нажимаю кнопку Отправить мои данные формы хранятся два раза в моей БД пожалуйста помогите так как я свежее не могу решить эту проблему
<?php /*Template name: gold loan enquiry */ get_header(); ?> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script> $(document).ready(function() { $("#source").change(function() { var el = $(this).children("option:selected").val(); if(el == "loan" ) { $("#status").show(); } else { $("#status").hide(); } }); document.getElementById('box').onchange = function(){ if(this.checked) alert("You receive calls"); else alert("You dont receive any calls"); }; }); </script> <style> .loans img{ display: none; } </style> <!-- breadcumb-area start --> <?php $backgroundImg = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' );?> <div class="breadcumb-area black-opacity bg-img-3" style="background-image: url('<?php echo $backgroundImg[0]; ?>'); background-position: initial;"> <div class="container"> <div class="row"> <div class="col-xs-12"> <div class="breadcumb-wrap"> <h2><?php the_title(); ?></h2> </div> </div> </div> </div> <div class="breadcumb-menu"> <div class="container"> <div class="row"> <div class="col-xs-12"> <ul> <li><a href="<?php echo site_url(); ?>">Home </a></li> <li>/</li> <li><?php the_title(); ?></li> </ul> </div> </div> </div> </div> </div> <!-- breadcumb-area end --> <section class="inner-area"> <div class="container"> <div class="row"> <div class="col-md-12"> <div class="section-title text-center wow fadeInUp"> <h2><?php the_title(); ?></h2> </div> <div class="col-md-7 remove-thum-img"><?php the_post_thumbnail($post_id, array( 50, 50) ); ?> </div> <?php // Start the loop. while ( have_posts() ) : the_post(); // Include the page content template. get_template_part( 'template-parts/content', 'page' ); // If comments are open or we have at least one comment, load up the comment template. if ( comments_open() || get_comments_number() ) { comments_template(); } // End of the loop. endwhile; ?> <br> <div class="row"> <div class="col-md-7 col-xs-12 fadeInRight wow"> <p style="text-align: left;">Enquire Now:</p> <div class="faq-form thumbnail well" style="padding: 20px 20px 3px 0;"> <div class="cf-msg"></div> <form class="form-horizontal" id="cf" action=""> <div class="form-group"> <label class="control-label col-sm-6">Name:</label> <div class="col-sm-6"> <input type="text" class="form-control" name="namess" required> </div> </div> <div class="form-group"> <label for="phoneno" class="control-label col-sm-6">Mobile Number:</label> <div class="col-sm-6"> <input type="tel" class="form-control" name="phone" id="phoneno" pattern="[0-9]*" maxlength="10" required> </div> </div> <div class="form-group"> <label for="acn" class="control-label col-sm-6">Customer with branch & A/c No:</label> <div class="col-sm-6"> <input type="text" class="form-control" name="account" required> </div> </div> <div class="form-group"> <label for="feedback" class="control-label col-sm-6">Feedback/Grievance details</label> <div class="col-sm-6"> <textarea class="form-control" name="feedback" required></textarea> </div> </div> <div class="form-group"> <div class="col-sm-offset-6 col-sm-6"> <button type="submit" name="submit" value="submit" class="btn btn-primary">Submit</button> </div> </div> </form> </div> </div> <?php global $wpdb; if(isset($_REQUEST["submit"])){ $namess=$_REQUEST["namess"]; $phone=$_REQUEST["phone"]; $account=$_REQUEST["account"]; $feedback=$_REQUEST["feedback"]; $to='kuldeep.kaluvala@gmail.com'; // Receiver Email ID, Replace with your email ID $subject='Form Submission'; $message="Name :".$name."\n"."Phone :".$phone."\n"."Wrote the following :"."\n\n".$msg; $headers="From: ".$email; if(mail($to, $subject, $message, $headers)){ echo "<h1>Sent Successfully! We will contact you shortly!</h1>"; } else{ echo "Something went wrong!"; } $sql="insert into grievance_enquiry (namess,phone,account,feedback)values('".$namess."','".$phone."','".$account."','".$feedback."')"; $status = $wpdb->query($sql); if($status>0){ echo "<script type='text/javascript'>alert('submitted successfully!')</script>"; } } ?> </div> </div> </div> </div> </section> <?php get_footer(); ?> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.5.0/css/bootstrap-datepicker3.min.css"> <script type='text/javascript' src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.5.0/js/bootstrap-datepicker.min.js"></script> <script type='text/javascript'> $(function(){ $('.input-group.date').datepicker({ format: 'yyyy-mm-dd', minViewMode: 0, calendarWeeks: true, todayHighlight: true, autoclose: true }); }); </script>
Что я уже пробовал:
Пожалуйста помогите мне быстро я должен закрыть этот вопрос как можно скорее