[英]Wordpress, html form only running php if missing fields and giving a 404 if all fields are filled?
I am currently creating a form on one of my templates in Wordpress but every time I submit the form with all fields filled in I get a 404 error:我目前正在 Wordpress 中的一个模板上创建一个表单,但每次我提交填写了所有字段的表单时,我都会收到 404 错误:
It posts correctly if some or all of the fields have been missed though.如果遗漏了部分或全部字段,它会正确发布。
HTML Form: HTML 表单:
<form method="POST" id="ageGatewayForm" action="">
Day: <input type="text" name="day">
Month: <input type="text" name="month">
Year: <input type="text" name="year">
<input type="submit" value="submit" name="submit">
</form>
PHP code on same page:同一页面上的 PHP 代码:
if(isset($_POST["submit"])){
if(!empty($_POST["day"]) && !empty($_POST["month"]) && !empty($_POST["year"])){
//do something
} else {
//do something
}}
Try 尝试
if(isset($_POST['day']))
or
if($_POST('day')=="")
All the 5 steps on this question should help submit your form with the right settings Form Action/Sub Question 此问题的所有5个步骤均应有助于通过正确的设置提交表单。表单操作/子问题
Good Luck! 祝好运!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.