Cocos2dx-3.3 network programming (CURL + PHP) NO.1 write PHP code in order to try network programming, read a lot of blog, now will this record in case of forgetting.
Before writing the connection code, we must do the following:
1. set up WAMP
2. create a database
3. write the PHP code.
4. test
I. WAMP construction
WAMP is easy to build. download and install it.
II. create a database
(Sorry, the password is wrong. it indicates that the following passwords are all wrong !)
3. write the PHP code check. php:
Deprecated: mysql_connect (): The mysql extension is deprecated and will be removed in the future: use mysql...$ Us = $ _ GET ["name"]; // GET data using GET method $ ps = $ _ GET ["passward"]; // 1. connect to the database $ conn = mysql_connect ("127.0.0.1", "root", "123456"); // 2. open the database mysql_select_db ("testphp"); // 3. create a query $ SQL = "select * from users where name = '". $ us. "'and passward = '". $ ps. "';"; // 4. execute this query $ result = mysql_query ($ SQL); $ n = mysql_num_rows ($ result); // return the number of results found // 5. close the database mysql_close ($ conn); if ($ n> 0) // if the number of results found is greater than 0, there is a user name and password and the passed parameters 1 { Session_start (); $ row = mysql_fetch_array ($ result); // Obtain the query result row // var_dump ($ row); // output the query result, echo "1"; // The server returns a "1"} else {echo "0"; // if no result is found, the server returns "0"}?>
IV. test
In the browser, enter http: // 127.0.0.1/check. php? Name = banana & passward = 123456
Check if a "1" is returned. If yes, the first step is successful ~
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.