Any Security holes in this php code? -


i found structure of following code on site, , i'm using it, want know if there security holes can exploited code, if can improved or if @ there deprecated elements shouldn't use.

i'll using following otp code through sms.

<?php function randomcode(){ $alphabet = "abcdefghijklmnopqrstuvwxyz0123456789"; $code = array(); $alphalength = strlen($alphabet) - 1; ($i = 0; $i < 6; $i++){ $n = rand(0, $alphalength); $code[] = $alphabet[$n]; } return implode($code);// turn array string } echo randomcode(); ?> 

beginner

upd. rewrote code bit:

function randomcode(){     $alphabet = "abcdefghijklmnopqrstuvwxyz0123456789";     $code = "";     $alphalength = strlen($alphabet) - 1;     ($i = 0; $i < 6; $i++){         $code .= $alphabet[rand(0, $alphalength)];     }     return $code; } echo randomcode(); 

upd2. secure, if block code after 3 wrong attempts.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -