简体   繁体   中英

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:

It posts correctly if some or all of the fields have been missed though.

HTML Form:

    <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:

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

Good Luck!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM