In the fabrik 2.0 forum I found a thread about string random code generator
http://fabrikar.com/forums/showthread.php?t=12269&highlight=random+string
I need to generate a random code to be saved in database
After submitting the form that would be used by users, I need:
To check if the code is not repeated
options:
(yes) run the php code again
(no) save info into database
This would be a hidden element and I also need to sent an email to the user with it's respective "string random code"
Question:
Is the PHP code enough to achived what I need?
How can I sent the email to the user?
http://fabrikar.com/forums/showthread.php?t=12269&highlight=random+string
I need to generate a random code to be saved in database
After submitting the form that would be used by users, I need:
To check if the code is not repeated
options:
(yes) run the php code again
(no) save info into database
This would be a hidden element and I also need to sent an email to the user with it's respective "string random code"
Question:
Is the PHP code enough to achived what I need?
How can I sent the email to the user?
PHP:
$length = 7;
$key = "";
// define possible characters
$possible = "0123456789bcdfghjkmnpqrstvwxyzBCDFGHJKLMNPQRTVWXYZ";
$i = 0;
while ($i < $length) {
$char = substr($possible, mt_rand(0, strlen($possible)-1), 1);
$key .= $char;
$i++;
}
return $key;