如何在没有数据库的情况下计算网站联系表单提交的数量 [英] How to count website contact form submissions without database

查看:72
本文介绍了如何在没有数据库的情况下计算网站联系表单提交的数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的,并且对SMTP邮件PHP功能有疑问。
我创建了一个联系表单,可以向公司发送HTML电子邮件。

Hi I'm new here and have a question about SMTP mail PHP function. I created a contact form which sends an HTML email to the company.

现在,我被要求为从网络发送的每封电子邮件创建一个计数器页,这样他们就可以知道有多少人正在请求有关该产品的信息。我读到没有数据库,这是不可能的,我们没有在这个项目中使用它,但是我正在考虑使用XML计数器来完成它。

Now I've been asked to create a counter for every email sent from the web page, so they can know how many people are requesting information about the product. I read that is not possible without a database, which we're not using for this project, but I was thinking about doing it with an XML counter.

这是更好的方法,还是还有其他可能?

Is this the better way, or there's other possibilities for this?

推荐答案

不,您不需要xml。一个简单的文件即可:

No, you don't need xml. A simple file will do:

counts.txt:

counts.txt:

0

counter_update.php:

counter_update.php:

<?php

$count = trim(file_get_contents('counts.txt'));
$count++;
file_put_contents('counts.txt', $count);

如果系统中度繁忙,则可能需要添加一些文件锁定,以便使用两个并行邮件脚本不会浪费对方的计数增量,但这是您所需要的基础。

If your system is moderately busy, you may want to add in some file locking so two parallel mail scripts won't trash each other's count increments, but this is the basics of what you need.

这篇关于如何在没有数据库的情况下计算网站联系表单提交的数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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