Bad Wolf PHP learning counter instance code

Source: Internet
Author: User

Create a file as follows. Connect to the database in step 1st, write the file, and then read it. CopyCode The Code is as follows: <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?
$ 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 a connection (servo server location, user name, user password)
$ conn = mysql_connect ($ mysql_server_name, $ mysql_username, $ mysql_password );
// prepare the SQL syntax. This syntax reads data.
$ SQL = "select count (*) from 'num' where name = 'badwolf '";
// query
$ result = mysql_db_query ($ mysql_database, $ SQL, $ conn );
// capture the query result
$ ROW = mysql_fetch_row ($ result );
// print all columns of the Data
// print_r ($ row);
// clear the query result
mysql_fre E_result ($ result);
?>



Bad Wolf security net PHP counter

<Body>
<Div align = "center" class = "style1">
<P> Bad Wolf security net PHP counter </P>
<H1> <SPAN class = "style3"> <? = $ Row [0];?> </Span> Number of people </Div>
</Body>

</Html>

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.