Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Losowanie hasła do pola tekstowego
Nidils
post
Post #1





Grupa: Zarejestrowani
Postów: 5
Pomógł: 0
Dołączył: 27.04.2011

Ostrzeżenie: (0%)
-----


Mam formularz do wypełnienie i chciałbym, żeby obok pola hasło był button generuj i po kliknięciu generowało by hasło do tego pola tekstowego. Mam już zrobione losowanie hasła, ale nie wiem jak zrobić ten button.

  1. <?php
  2.  
  3. function passwordGenerator($length)
  4. {
  5. $uppercase = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'R', 'S', 'T', 'U', 'W', 'Y', 'Z');
  6. $lowercase = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'r', 's', 't', 'u', 'w', 'y', 'z');
  7. $number = array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
  8. $password = null;
  9. for ($i = 0; $i < $length; $i++) {
  10. $password .= $uppercase[rand(0, count($uppercase) - 1)];
  11. $password .= $lowercase[rand(0, count($lowercase) - 1)];
  12. $password .= $number[rand(0, count($number) - 1)];
  13. }
  14. $haslo = substr($password, 0, $length);
  15. return $haslo;
  16. }
  17. ?>
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 20.08.2025 - 13:50