I've made a custom form and made a custom plugin of it to send email and store data into database, everything is working fine. I am using PHP mailer for sending email & using SQL query for storing data into my database table but issue is: after every two minutes it is keep sending empty Email to my mail address and keep storing empty fields into my database.
I've used isset empty validation but it is not working here which prevents from storing empty data into database in PHP but not working in WordPress using custom plugin.
if(isset($_POST) & !empty($_POST)){
$name = $_POST['name'];
if(!isset($name) || empty($name)){
$error[] = "Name is required";
}
I am new in WordPress just started working here, please tell me how to prevent from storing empty fields into database or which validation/function should I use to prevent empty data fields in WordPress.