简体   繁体   English

提交后禁用联系表单输入字段

[英]Disable contact form input fields after submit

This is my first time asking a question.这是我第一次提问。

I have a website where you log in, and after login, you can submit a form.我有一个网站,您可以在其中登录,登录后可以提交表单。 (Contact form 7). (联系表 7)。

I want the input fields to disable after the user have submitted a form, so he can only submit that form 1 time (I have 6 forms total).我希望在用户提交表单后禁用输入字段,因此他只能提交该表单 1 次(我总共有 6 个表单)。

My first thought was to insert a row in the database with the username and 0 (Not submitted) or 1 (Submitted).我的第一个想法是在数据库中插入一行,其中包含用户名和 0(未提交)或 1(已提交)。 If 1, then disable form, or if 0, then you can submit a form.如果为 1,则禁用表单,如果为 0,则可以提交表单。

My problem is that i can't get wordpress to insert anything in the database.我的问题是我无法让 wordpress 在数据库中插入任何内容。 I tried this plugin at first: https://wordpress.org/plugins/contact-form-cfdb7/我一开始尝试了这个插件: https : //wordpress.org/plugins/contact-form-cfdb7/

and it kind of worked, but now the plugin doesn't insert anything in the database anymore.它有点工作,但现在插件不再在数据库中插入任何内容。 I have no idea why.我不知道为什么。 I haven't changed anything.我没有改变任何东西。

When i insert some php / sql code in functions.php, then when i submit the form, it's just loading.当我在functions.php 中插入一些php/sql 代码时,然后当我提交表单时,它只是加载。 Nothing happens.没发生什么事。

Just add the below code to your input tag which you want to disable只需将以下代码添加到您要禁用的输入标签中

<?php echo (isset($_POST['submit'])) ? 'disabled' : ""; ?> 
//if submit method is POST else use $_GET for get method

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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