How to count website contact form submissions without database [closed]

*爱你&永不变心* 提交于 2020-01-07 08:54:07

问题


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.

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?


回答1:


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

counts.txt:

0

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.



来源:https://stackoverflow.com/questions/15814591/how-to-count-website-contact-form-submissions-without-database

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!