我的网站(Wordpress)上有许多正在使用的表单,这些表单使用method =“ post”将PHP文件用作表单上的“操作”。一切都很好,但是我收到了大量空白的表单,这是在直接访问PHP处理程序时发生的(因为通过直接访问处理程序文件绕过了我的前端表单验证,并且处理程序包括wp_mail功能来发送电子邮件)。
我正在尝试找出如何防止直接访问处理程序文件,而不通过阻止对处理程序的访问来破坏表单。如果说得通?
表格
System.out.println("The letter at position " + i + " is " + showCharacter(str,i));
处理程序
<form class="contact-form" action="<?=get_bloginfo('template_url') . '/path/to/my/handler-file.php' ?>" method="post" enctype="multipart/form-data">
<input type="text" id="first_name" name="first_name" placeholder="First name">
<label for="first_name">First name</label>
<input type="text" id="last_name" name="last_name" placeholder="Last name">
<label for="last_name">Last name</label>
<input type="email" id="email" name="email" placeholder="Your email">
<label for="email">Your email</label>
<button class="button" type="submit">Submit</button>
</form>