- /*
- 1. Generate Random Numbers
- 2. Inserting a table
- 3. Enquiry
- 4. Return Yes
- */
- function mak ()//Generate card number cipher algorithm can be replaced;
- {
- $str =md5 (Microtime ());
- $pass =substr ($STR,-12);
- return $pass;
- }
- Generate the card number password and deposit it into the database $times= the number of card numbers you want to add////////////////
- function Sqlconn ($times)
- {
- $con =mysql_connect ("127.0.0.1", "Root", "" ");
- if (! $con)
- {
- Die (' Connect database ...... '). [ERROR]: '. mysql_error ());
- }
- else echo "Connect to Database Server ......." [OK]
";
- $cmd = "CREATE DATABASE num_psw";
- if (mysql_query ($cmd, $con)) echo "creat database ......" [OK]
";
- Else
- {
- echo ' creat database ....... ..... [ERROR]: '. Mysql_error (). "
";
- }
- mysql_select_db ("NUM_PSW", $con);//Select Database
- $cmd = "CREATE table NUMPSW (auth1 varchar, auth2 varchar (25))";
- if (mysql_query ($cmd, $con)) echo "creat table ......" [OK]
";
- Else
- {
- echo ' creat table ....... ..... [ERROR]: '. Mysql_error (). "
";
- }
- for ($i =0; $i < $times; $i + +)
- {
- $tmp 1=mak ();
- $tmp 2=mak ();
- $cmd = "INSERT into NUMPSW values (' {$tmp 1} ', ' {$tmp 2} ')";
- if (mysql_query ($cmd, $con)) echo "Creat num ......" [OK]
Num is: $tmp 1 PSW is: $tmp 2 ";
- Else die (' creat num ......... [ERROR]: '. mysql_error ());
- }
- }
- Verify that the card number password is the correct parameter for the card number password///////////////////////
- function Sqlauth ($str 1, $str 2)
- {
- $con =mysql_connect ("127.0.0.1", "Root", "" ");
- mysql_select_db ("NUM_PSW", $con);
- $cmd = "SELECT * from NUMPSW WHERE auth2= ' {$str 2} '";
- $res =mysql_query ($cmd, $con);
- $row = Mysql_fetch_array ($res);
- if ($row [0]== $str 1) echo "Auth success!"; else echo "Auth failed!"; /Direct-Explicit;
- if ($row [0]== $str 1) return true;else return false;//interface;
- }
- ////////////////////////////////////////////////////////////////////////////
- Usage:
- Sqlconn (5);
- Sqlauth (' 207a2c9dac2d ', ' 3a97d69421c6 ')
- ?>
Copy Code
|
Point card, card number, PHP