I have the following problem: Two or more users on different computers are filling out a form and that form assigns them a sheet.
The folio is consulted according to the last one registered in the BD and returns the next folio to be used.
Example if the 00001
is already present and I am currently filling in a form assigns me the 00002
but the other person in another machine also assigns the 00002
before I save the information. When it saves the insertion to the BD the first to save it generates a folio 00002
and to me the 00003
but when I consult my folio 00003
the data of the person who was filling the form appears first.
Is there a way to book that folio while I do not click save to the record in the DB with PHP?
I clarify that I do not use AutoIncrement in my BD. What I do is the following when consulting if that page already exists:
error_reporting(E_ERROR | E_WARNING | E_PARSE);
$link = mysql_connect('localhost', 'root', '');
mysql_select_db('mb', $link);
$tmp1 = ("SELECT * FROM rprh06 ORDER BY FOLIO DESC");
$consulta1 = mysql_query($tmp1, $link);
$folio = mysql_num_rows($consulta1);
mysql_free_result($consulta1);
if ($folio == 0) {
$folio = $folio + 1;
} else {
$folio = $folio + 1;
}
if (strlen($folio) == 1) {
$folio = "0000" . $folio;
}
if (strlen($folio) == 2) {
$folio = "000" . $folio;
}
if (strlen($folio) == 3) {
$folio = "00" . $folio;
}
if (strlen($folio) == 4) {
$folio = "0" . $folio;
}
After this he shows me the next folio to use.