Hello guys, I'm new here, and i have this question without an answer till now.

So, what i want when people click on submit button on contact page, is that when e-mail is sended the Subject just update like... "Contact #00001"... when another people click it... it'll be sended like .. "Contact #00002" and etc..

I don't know if this is clearly enough, but i think you guys can understand, and i'll appreciate your help! thanks!!

Your email subject can contain a PHP variable so there is no problem inserting the contact # into the subject in your PHP program. After you read the current value of the counter from your database or file, you can increment it and write it back. If you save the value in a file, have a look at the flock command. You can use this to force the updating of the file to be serialized. You could have multiple users all trying to fill out the contact page at the same time so you need a way to deal with them one at a time when you are accessing and updating the counter. Mysql also allows you to implement locks and you can get some additional info here.

Ok, this is what i did to just get the message from ppl to my mail:


$msg = "\t$nome\n"."<br/>";
$msg .= "E-mail:\t$email\n"."<br/>";
$msg .= "Telefone:\t$telefone\n"."<br/>";
$msg .= "Cidade/CEP:\t$cidade\n"."<br/>";
$msg .= "Empresa:\t$empresa\n"."<br/><br/>";
$msg .= "\t$mensagem\n\n"."<br/>";

$cabecalho = "De: $email\n";
$cabecalho = "From: $email\n";
$cabecalho = "Para: C \n\n";
$cabecalho = "Content-type:text/html; charset=UTF-8\n";

$subject = "CR - Orçamento";

mail("chadalala@c.com.br", $subject, $msg, $cabecalho);

I searched google a lot, and i modified a code that i get on a site with php counter:


$counter = ("counter.txt"); 
$total = file('counter.txt'); 

if(isset($_POST['submit'])) { 
$total[0] ++; 
$f = fopen('counter.txt','w+');
fputs($f, "$total[0]"); 


But when i try to put this $total[0]++ on subject like this:

$subject = "CR - Orçamento echo $total[0];";

It gives an error(at least cause it's wrong), and i tried in many different ways, but nothing happens. As you see, i dont know much PHP, just the basic to modify something or other.

I read that it can be made with MYSQL as you say, but.. if it can be made with PHP, i think it'll be easier to me.

Thanks for the help,

The synatax is incorrect. Try:
$subject = "CR - Orçamento ".$total[0];

Thanks chrishea, but it still doesnt work. Maybe because it takes to another page... It's like when ppl click on Send, the person in will be sent to another page, and there is the php mail thing, i tried putting the code in this two pages, but nothing happens, just errors. Thanks anyway!