Generate An Authentication Code in PHP


SUBMITTED BY: Guest

DATE: Aug. 25, 2012, 10:06 p.m.

FORMAT: PHP

SIZE: 576 Bytes

HITS: 1564

  1. <?php
  2. # This particular code will generate a random string
  3. # that is 25 charicters long 25 comes from the number
  4. # that is in the for loop
  5. $string = "abcdefghijklmnopqrstuvwxyz0123456789";
  6. for($i=0;$i<25;$i++){
  7. $pos = rand(0,36);
  8. $str .= $string{$pos};
  9. }
  10. echo $str;
  11. # If you have a database you can save the string in
  12. # there, and send the user an email with the code in
  13. # it they then can click a link or copy the code
  14. # and you can then verify that that is the correct email
  15. # or verify what ever you want to verify
  16. ?>

comments powered by Disqus