Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function testarcode($code){
- global $link;
- if ($code == ""){
- return false;
- }
- $comando = "SELECT * FROM tbl_usuario WHERE code='$code'";
- $query = mysqli_query($link, $comando);
- if(mysqli_num_rows($query) > 0){
- return false;
- }
- else{
- return true;
- }
- }
- function gerarcode(){
- $caracteres = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
- $max = strlen($caracteres) - 1;
- $code = "";
- while (testarcode($code) == false){
- for($i=0; $i < 5; $i++) {
- $code .= $caracteres[mt_rand(0, $max)];
- }
- }
- return $code;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement