问题
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