I am looking into some code that was done for our basket by someone else. I intend to use similar code myself in the new web site I am writing. it is pasted below.
I realise this bit of code generates the customer transaction code. But what makes it random and unique? Why has the web designer used rand twice? Surely once would be fine!? And also how does this code always remember the codes used previously? The current site does not use MySQL. It just uses PHP in the basket but I can see no way it ensures it is unique. We have not encountered a problem with uniqueness of customer transaction numbers, so how does it make sure of this --- is it just lucky --- is there more than can be done --- particularly as the new site does use MySQL.
$VendorTxCode = "AGPS".(rand(0,32000)*rand(0,32000));