save a number from one webpage on the server side and being able to retrieve it

StackOverflow https://stackoverflow.com/questions/23438413

  •  14-07-2023
  •  | 
  •  

Вопрос

i have a website for E-invoice. I'm trying to find the best way where i can retrieve a number "in my case the invoice number" and when creating a new invoice the old number will be saved somewhere and retrieved to be +1.

for now i know that i can't use cookies or session of course and i can't use HTML5 local storage to save the last invoice number and i know that it have to be something on the server side.

can i use xml or save the value in a text file then retrieve it? can anyone please inform me of the best approach to do this.

Это было полезно?

Решение

here a possible solution (untested)

<?php
$file = fopen("number.txt","rw");
$number = fread($file);
$number += 1;  //the new number to proceed
fwrite($file,$number);
fclose($file);
?>
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top