防止使用PHP的多个条目 [英] Prevent Multiple Entries using PHP

查看:132
本文介绍了防止使用PHP的多个条目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

与网页上的投票设施并列显示的是以下输入字段,使访问者(投票人)能够以抽奖的形式输入他们的细节,作为他们参与投票的努力的奖励。

抽奖条目表单脚本未附加到投票脚本。抽奖条目表单脚本中的所有输入都将进行验证,并将信息发送到平面文件。这是一个短期的民意测验,只需7天就可能在小城镇论坛上不时发生的不同主题进行调查。 (ip也被收集)

 名称:< input type =textname =visitor/>< br />< br /> 
电子邮件:< input type =textname =visitormail/>< br />< br />
电话:< input type =textname =visitorphone/>< br />< br />

提交时,'谢谢你'页面建议访问者他们的详细信息将在一次中用于篮子的抽奖。换句话说,访问者可以返回并重新填写表单并提交,要求我在完成篮子的随机数绘制之前检查并清除平面文件中的多个条目!



问题是否有一种简单的方法来安装防止访问者尝试多次输入到绘图中的内容? $ b

解决方案

我也会记录IP(请参阅 $ _ SERVER 变量)。然后你可以通过IP缩小重复数。并不总是最简单的方法。



另一种方法可能是cookie。


Presented alongside a polling facility on a webpage is the following input fields that enables the visitor (voter) to enter their details in a raffle for a hamper as a reward for their effort in taking part in the poll.

The raffle entry form script is not attached to the poll script. All inputs in the raffle entry form script are validated and the info is sent to a flatfile. It is a short poll lasting only 7 days on different topics that might arise from time to time for a small town forum. (ip is also collected)

Name  :<input type="text" name="visitor" /><br /><br />
Email :<input type="text" name="visitormail" /><br /><br />
Phone :<input type="text" name="visitorphone"/><br /><br />

On submission the 'Thank You' page advises the visitor that their details will be used once in the raffle for the hamper. In other words the visitor could go back and fill in the form again and submit, requiring that I check for and weed out multiple entries from the flatfile before completing the Random Number draw for the hamper!

The Question Is there a simple way to install something that prevents the visitor from attempting multiple entries into the draw?

解决方案

I would log the IP as well (see $_SERVER variable). Then you can narrow down duplicates by IP. Not always the most fool proof method.

Another approach could be a cookie.

这篇关于防止使用PHP的多个条目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆