自定义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?

dongmei3498
dongmei3498 客户端,所以他可以随时编辑自己-你有没有看过像Formidable这样的表单插件?en-gb.wordpress.org/plugins/formidable
接近 4 年之前 回复

3个回答



你必须按照你的主题文件夹下的page.that_file.php这样的WordPress文件结构,并在其中调用页眉和页脚并点击 页面检查它是否工作。 检查后,在您的操作表单中调用该页面仍然会在您的调用函数中发出404而不是问题。 </ p>
</ div>

展开原文

原文

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.



你应该使用强大的 ACF 来构建您的表单 ,您可以减少表单上任何更新的时间,此外,您可以在仪表板中查看管理用户响应的视图,这对您来说应该更容易。</ p>
</ div>

展开原文

原文

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.



谢谢大家我找到了办法。 我使用联系表格7表格和CFDB插件将表格数据保存到数据库。</ p>

我必须在提交后发送确认电子邮件,以便联系表格7为我做了。</ p>

</ div>

展开原文

原文

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.

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问