PHP Implementation point card number password generation

Source: Internet
Author: User
  1. /*
  2. 1. Generate Random Numbers
  3. 2. Inserting a table
  4. 3. Enquiry
  5. 4. Return Yes
  6. */
  7. function mak ()//Generate card number cipher algorithm can be replaced;
  8. {
  9. $str =md5 (Microtime ());
  10. $pass =substr ($STR,-12);
  11. return $pass;
  12. }
  13. Generate the card number password and deposit it into the database $times= the number of card numbers you want to add////////////////
  14. function Sqlconn ($times)
  15. {
  16. $con =mysql_connect ("127.0.0.1", "Root", "" ");
  17. if (! $con)
  18. {
  19. Die (' Connect database ...... '). [ERROR]: '. mysql_error ());
  20. }
  21. else echo "Connect to Database Server ......." [OK]
    ";
  22. $cmd = "CREATE DATABASE num_psw";
  23. if (mysql_query ($cmd, $con)) echo "creat database ......" [OK]
    ";
  24. Else
  25. {
  26. echo ' creat database ....... ..... [ERROR]: '. Mysql_error (). "
    ";
  27. }
  28. mysql_select_db ("NUM_PSW", $con);//Select Database
  29. $cmd = "CREATE table NUMPSW (auth1 varchar, auth2 varchar (25))";
  30. if (mysql_query ($cmd, $con)) echo "creat table ......" [OK]
    ";
  31. Else
  32. {
  33. echo ' creat table ....... ..... [ERROR]: '. Mysql_error (). "
    ";
  34. }
  35. for ($i =0; $i < $times; $i + +)
  36. {
  37. $tmp 1=mak ();
  38. $tmp 2=mak ();
  39. $cmd = "INSERT into NUMPSW values (' {$tmp 1} ', ' {$tmp 2} ')";
  40. if (mysql_query ($cmd, $con)) echo "Creat num ......" [OK]
    Num is: $tmp 1
    PSW is: $tmp 2
    ";
  41. Else die (' creat num ......... [ERROR]: '. mysql_error ());
  42. }
  43. }
  44. Verify that the card number password is the correct parameter for the card number password///////////////////////
  45. function Sqlauth ($str 1, $str 2)
  46. {
  47. $con =mysql_connect ("127.0.0.1", "Root", "" ");
  48. mysql_select_db ("NUM_PSW", $con);
  49. $cmd = "SELECT * from NUMPSW WHERE auth2= ' {$str 2} '";
  50. $res =mysql_query ($cmd, $con);
  51. $row = Mysql_fetch_array ($res);
  52. if ($row [0]== $str 1) echo "Auth success!"; else echo "Auth failed!"; /Direct-Explicit;
  53. if ($row [0]== $str 1) return true;else return false;//interface;
  54. }
  55. ////////////////////////////////////////////////////////////////////////////
  56. Usage:
  57. Sqlconn (5);
  58. Sqlauth (' 207a2c9dac2d ', ' 3a97d69421c6 ')
  59. ?>
Copy Code
Point card, card number, PHP
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.