Cocos2dx-3.3 network programming (CURL + PHP) NO.1 write PHP code

Source: Internet
Author: User
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.

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.