How to insert a random number into the email?

da dave18 11 Nov, 2015
Hello, I have a form that sends and email with the data to the administrator and a "Thank you" email to the sender.

I am not saving anything into any database.

I just need to insert a random number/string within both emails so that the administrator will get something like this:
"A new user filled the form. His ID is 123abc"

and the sender will receive something like this:
"Thanks for your registration. Your registration number is 123abc"

I don't need a duplicate-number-check because the chance they will be the same would be very low.

The amount of number can be 6 or 10 or 12 or whatever. I have searched quite some time within the form but I did not find anything.

Thanks.
Gr GreyHead 11 Nov, 2015
Hi dave18,

You can use a Custom Code action with a few lines of PHP to generate a random string - you can find plenty of examples with Google e.g. this StackOverFlow answer.

Bob

PS If you were saving to a database table I have a Unique ID [GH] action that will do the work for you.
Zy Zyraj 03 Aug, 2017
Hey Bob, mind sharing your action?😀
Max_admin Max_admin 03 Aug, 2017
1 Likes
Hi Zyraj,

In v6 you can use {uuid:} or {rand:}

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Gr GreyHead 10 Aug, 2017
Hi Zyraj,

Which version of ChronoForms are you using? My action is for CFv5 only.

Bob
in indiana71 29 Aug, 2017
Hi, Max.

{uuid:} or {rand:} may be used to store a Real UniqueID into database?

Which one is better?

And how long is the string returned?

(CF6)
Gr GreyHead 30 Aug, 2017
1 Likes
Hi indiana71,

I think that both of these will return quite long random strings - the uuid in CFv5 is 64 characters. And while they will almost certainly be unique there is no check for that.

If you want a short user friendly string then you can generate that in a custom action and check that it has not already been used.

Bob
This topic is locked and no more replies can be posted.