First enter phpmyadmin to create a database named db, and then create several tables. name indicates the access count of the user badwolf, IP indicates the access IP address, and new indicates the access IP address. create a file as follows. connect to the database in step 1st, write the file, and then read it.
The code is as follows:
$ Mysql_server_name = "localhost ";
$ Mysql_username = "root ";
$ Mysql_password = "";
$ Mysql_database = "db ";
// Capture ip addresses
$ Ip = getenv ("REMOTE_ADDR ");
// Establish a line-through (servo server location, user name, user password)
$ Conn = mysql_connect ($ mysql_server_name, $ mysql_username, $ mysql_password );
// Prepare SQL syntax. this syntax is newly added.
$ SQL = "INSERT INTO 'num' ('name', 'IP', 'new') VALUES ('badwolf ',' $ IP', '1 ');";
// Select the database you want to process
Mysql_select_db ($ mysql_database, $ conn );
// Query
$ Result = mysql_query ($ SQL );
// Result and release the link
Mysql_close ($ conn );
//------------------------------------------------------------------
// Print the following information
// Establish the connection (servo server location, user name, user password)
$ Conn = mysql_connect ($ mysql_server_name, $ mysql_username, $ mysql_password );
// Prepare SQL syntax. this syntax is used to read data.
$ SQL = "SELECT COUNT (*) FROM 'num' WHERE name = 'badwolf '";
// Query
$ Result = mysql_db_query ($ mysql_database, $ SQL, $ conn );
// Capture the query results
$ Row = mysql_fetch_row ($ result );
// Print all columns of the data
// Print_r ($ row );
// Clear the query results
Mysql_free_result ($ result );
?>
Bad Wolf safety net php counter
Bad Wolf safety net php counter
So far Times