Today in my form, I have the mail.php file where I read the form data and send it by email. This form is an online order form, where registered users log in and place orders. Well, I set up everything based on research and studies on the web, I'm not a knowledgeable php language, but I understand a little. Today I got to put the code (below), to generate the random numbers with the rand () function, so as not to run the risk of repeating numbers I found this formula:
<?
$numeros = array(0,1,2,3,4,5,6,7,8,9);
$total_num = count($numeros)-1;
$numPedido = $id . $numeros[rand(0,$total_num)] . $numeros[rand(0,$total_num)] . $numeros[rand(0,$total_num)] ;
$gerador = $numPedido;
?>
Well, solved, generate numbers without the need of Database, but would like to use sequential, how? Is there any function, in javascript, I do not know, that can save the information of the number in TXT file and then consult the file not to repeat the number?
I have already found several tutorials on using DB, but found it complicated. Since the order form is not saved anywhere, it is only sent by email, we only use the BD to load user data and of course, to have access to the order online.
This code I used put in the mail.php file. So the number appears in the body of the email and I put it to appear also in the subject.
Thanks in advance for your attention!