In order to try the network programming, read a lot of great God's blog, now this record to prevent forgetting.
We have to do a few things before we write the connection code:
1. Build Wamp
2. Create a database
3. Write the PHP code well
4. Testing
A: Build Wamp
Wamp construction is very convenient, download and installation can be
Two: Create a database
(Sorry password wrong, here to explain, the following password are wrong!) )
Three: Write good PHP code check.php:
Deprecated:mysql_connect (): The MySQL extension is Deprecated and would be a removed in the Future:use MySQL ... $US =$_get["name"]; Get data with Get $ps= $_get["Passward"]; 1. Connect the database $conn = mysql_connect ("127.0.0.1", "root", "123456"); 2. Open the database mysql_select_db ("testphp"); 3. Create a new query $sql = "SELECT * from users WHERE name = '". $US. "' and Passward = ' ". $ps. "';"; 4. Execute this query $result = mysql_query ($sql); $n = mysql_num_rows ($result); Returns the number of results found //5. Close Database mysql_close ($conn); if ($n >0)//If the number of results found is greater than 0, that is, the user name and password with the passed in parameters one to { session_start (); $row = Mysql_fetch_array ($result); Get query results that line //var_dump ($row);//Output query results, there is no need for echo "1"; The server returns the client a "1" } else { echo "0"; No results found, return "0" } ?>
Four: Testing
Now in the browser to enter: http://127.0.0.1/check.php?name=banana&passward=123456
See if it returns a "1" and if so, then the first step is successful.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.