Hello My Success-Oriented Friends,
Is it possible to limit the generated confirmation code to a specific limit, that is may be to general a 20 digits confirmation code.
Regards,
adsegzy
limiting confirmation code
Moderator: General Moderators
Re: limiting confirmation code
I really hate to ask this... but,
What generated confirmation code?
No code? No reference? No hint?
Im sure when i did a php.net search for a confirmation function it didnt return one
What generated confirmation code?
No code? No reference? No hint?
Im sure when i did a php.net search for a confirmation function it didnt return one
Re: limiting confirmation code
Hello Weiry,
Is it that you dont know how to generate confirmation code? let me know so that i can post the code for genenrating confirmation code.
Is it that you dont know how to generate confirmation code? let me know so that i can post the code for genenrating confirmation code.
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
Re: limiting confirmation code
Create a whitelist of characters that can be in the confirmation code, and randomly add them to the code.
Code: Select all
function generateConfirmationCode($length = 30) {
$whitelist = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$confirmationCode = "";
for ($i = 0; $i < $length; $i++) {
$confirmationCode .= $whitelist[rand(0, strlen($whitelist) - 1)];
}
}Re: limiting confirmation code
If you state your questions more carefully, i can answer better. You ask is it possible, but you make no reference to that you are actually asking for a confirmation code script. So if you were using a script you already had, i wouldnt know, but if you made one yourself, then yes it is possible.adsegzy wrote:s it possible to limit the generated confirmation code to a specific limit,
superdezign posted one way of doing it, and here is mine:
Code: Select all
function getConfirmation($length){
$returnArray = array();
for($i = 0; $i<$length; $i++){
array_push($returnArray,chr(mt_rand(63,126)));
}
return implode($returnArray);
}
print getConfirmation(20);Normally i would set the mt_rand() between 33,126 but i was experiencing a problem with a few of the symbol ascii characters.