自定义wordpress表单提交

I want to insert data into database table through custom php form in wordpress. I don't want to use/create plugins/hooks. just simple form for client so he can edit himself whenever he want.

I tried

if($_POST['submit'])
{< submit to db >
} else {
< display html form ><br>
}


with action="" . this redirect to the same page without any error on page + in console. javascript validations on fields are working perfect.

I tried another solution by creating a php file in themes folder, and setting action="../that_file.php", which gave 404 error.

Any other solution?

you have to follow the WordPress file structure like page.that_file.php under your theme folder and calling header and footer in it and hit the page to check it work or not. After checking it call the page in your action form still you get 404 than issue in your calling function.

You should use Formidable or ACF to build your form, you will lose less time for any update on your form, also, you could have a view in the dashboard to manage your user's response, that should be easier for you.

Thanks guys I found a way. I use Contact form 7 for form and CFDB plugin to save that form data to db.

I had to send confirmation email after submission so Contact form 7 did it for me.