php表单提交计数器
因此,我为该客户制作了一个极其简单的 4 页静态网页,其中包含由 php 处理的快速联系表单。一切都很顺利。
然后客户来找我并请求他能够查看已提交的数量的计数器。因此,他通常希望为他的表单提供一个计数器,这很简单,因为我只需为使用该表单发送的每封成功的电子邮件添加一个计数器,并将其保存在某种数据存储中。
但是......
我能想到的唯一方法是有一个单独的用户页面,其中有一个简单的框,里面有号码,只有客户端可以访问。
我可以这样做...将计数器保存在一个 xml 文件或一个表、一列、一行 mySQL 数据库中。
但是有没有更好更简单的方法来做到这一点???我可以建立一个与谷歌分析或其他东西的链接吗?而不是制作一个带有数字的单页。
So I've made an extremely simple 4 page static webpage for this client with a quick contact form handled by php. Everything goes swimmingly.
Then the client comes to me and requests that he is able to see a counter of how many submits have been made. So he generally wants a counter for his form, Which is simple enough because I just add a counter for every successful email sent using the form and save it within some kind of data storage.
BUT...
the only way I can think to do it is have a separate user page with a simple box that has the number in it, that only the client can access.
I could do this... Save the counter in an xml file or a one table, one column, one row mySQL database.
But is there a better easier simpler way to do this??? Can I set up a link with Google analytics or something? Rather than making a single page with a number on it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议使用单独的页面供客户查看计数。您可以使用.htaccess 来控制对此页面的访问。主要原因是期待未来客户的要求。然后,他们很可能会要求您显示指定时间段的计数、每天/每周/每月的计数等。如果您现在设置页面,那么您可以进行自定义/扩展。
至于存储计数器,我建议存储的不仅仅是总数。有一个表格,用于存储:
然后要显示总数,您只需
从 that_table 中选择 count(1)
以及任何所需的日期/等。分组。I suggest going with a separate page for the client to view counts. You can use .htaccess to control the access to this page. The main reason is looking forward to future client requests. Most likely, they will then ask you to show counts for specified periods of time, counts per day/week/months, etc. If you set up your page now, then you can have place to customize/extend.
As for storing the counter, I would suggest storing more than just the total. Have a table where you'd store:
Then to display the totals, you'd just
select count(1) from that_table
with any required date/etc. grouping.