alanrg.83 0 Denunciar post Postado Junho 25, 2007 Pessoal como faço para gerar uma espécie de protocolo.Gostaria de saber como faço pra gerar uma combinação randomica de numeros e letras com 10 digitos. Para gerar uma espécie de protocolo. Compartilhar este post Link para o post Compartilhar em outros sites
Fabinho-WEB 0 Denunciar post Postado Junho 25, 2007 Olha da pra fazer assim..<?$aux = $user.time(); $senha = substr(md5($aux),0,10); echo $senha ?> Compartilhar este post Link para o post Compartilhar em outros sites
raphaeltsr 0 Denunciar post Postado Junho 25, 2007 Olha da pra fazer assim..<?$aux = $user.time(); $senha = substr(md5($aux),0,10); echo $senha ?>De onde vem essa $user?Olhando na página do rand() no php.net eu achei um script que enviaram pra lá mto interessante.Não testei, mas transcrevi para facilitar:<?php /** * Key Generator * * @param int Length of the key * @param string Type of Character * (lower, upper, numeric, ALPHA, ALNUM) * * @return string Generated key from the arguments */ function mKey($len = 12, $type = 'ALNUM') { // Register the lower case alphabet array $alpha = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'); // Register the upper case alphabet array $ALPHA = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'); // Register the numeric array $num = array('1', '2', '3', '4', '5', '6', '7', '8', '9', '0'); // Initialize the keyVals array for use in the for loop $keyVals = array(); // Initialize the key array to register each char $key = array(); // Loop through the choices and register // The choice to keyVals array switch ($type) { case 'lower' : $keyVals = $alpha; break; case 'upper' : $keyVals = $ALPHA; break; case 'numeric' : $keyVals = $num; break; case 'ALPHA' : $keyVals = array_merge($alpha, $ALPHA); break; case 'ALNUM' : $keyVals = array_merge($alpha, $ALPHA, $num); break; } // Loop as many times as specified // Register each value to the key array for($i = 0; $i <= $len-1; $i++) { $r = rand(0,count($keyVals)-1); $key[$i] = $keyVals[$r]; } // Glue the key array into a string and return it return join("", $key); } ?>Pode ser que ajude! Compartilhar este post Link para o post Compartilhar em outros sites
Fabinho-WEB 0 Denunciar post Postado Junho 25, 2007 o $user você usuaria caso queira incluir o nome mais naum precisa te-lo nescessariamente testa o codigo pra você ver ele gera a senha ou protocolo normal usando a hora atual com md5 para criar aleatoriamente intao nunca ira se repetir..Abraço..o codigo acima tbm funciona normalmente .....abraçosss Compartilhar este post Link para o post Compartilhar em outros sites