我正在使用一个简单的表单发送一些数据。用户必须登录才能访问表单(我有一个包含用户和密码的数据库)。
我想要做的是限制用户成功提交表单的次数,这是基于这样的响应: mysite.com/send.php?code=0 (其中只有0表示成功,其他值表示错误)。
我可以在数据库中手动添加此限制,但我真的不知道如何绕过此限制。
发布于 2014-03-13 05:36:59
下面是一个如何实现所需功能的示例。在不知道你的特性的哪些部分有问题的情况下,这是我所能做的最好的事情。如果有什么不清楚的地方,请提出问题。
HTML表单
<form method="post" action="myUrl">
<input name="myField"/>
<input type="submit"/>
</form>处理表单的PHP
if(isset($_POST["myField"])){
if(userHasNotSubmittedForm($_SESSION["userIdOrSomething"])){
//update the column here with a database query
}
else{
//tell the user they have already submitted this form.
//Ideally, the user shouldn't be able to see this page
//if they have already submitted this form, but this
//behavior matches what you asked for.
}
}https://stackoverflow.com/questions/22363557
复制相似问题