PHP Random Number Question

Hey all! I know that I can use rand() to generate a random number.

But what I want to do is generate a number starting from 100001 when a user submits a form on my website (as a confirmation number). Then the next time a user submits the form, I want the confirmation number to be 1-digit higher, and so on so on (+1 each time).

How can I accomplish this?

Further more, I want that confirmation number to both echo back to the user on a confirmation screen, but then shoot an email to me with all of the form data INCLUDING the confirmation number that was generated.

How can I accomplish this?

Add 100001 to a counter field in the users table when creatibg users. Increase by 1 for each form submission

I’m not using a database…just a form handler to email the result. Will I need a database to accomplish this?

You need some kind of persistant storage, you can save it to a file if you want.

Do you want one counter for each user or one counter for the entire site / all submissions?

The counter would be just for that specific URL/form/directory. How would I create a file do accomplish. Sorry, not sure where to start?

Sponsor our Newsletter | Privacy Policy | Terms of Service