当我在表单数据中单击提交按钮两次存储时,能否请您尽快解决此问题
<?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);
}
答案 0 :(得分:0)
尝试一下:
$sql = "insert into grievance_enquiry
(namess,phone,account,feedback)values
('".$namess."','".$phone."','".$account."','".$feedback."')";
$status = $wpdb->query($sql);
if ($status === TRUE) {
echo "New record created successfully";
}
else{
echo" not created";
}
答案 1 :(得分:0)
我认为您应该使用jQuery禁用“提交”按钮。意味着一旦单击“提交”按钮,则应禁用“提交”按钮以防止多次提交。
这是代码:
$(function()
{
$('#theform').submit(function(){
$("input[type='submit']", this)
.val("Please Wait...")
.attr('disabled', 'disabled');
return true;
});
});