Home > Backend Development > PHP Tutorial > Access server database through php file in cocos2dx (2)

Access server database through php file in cocos2dx (2)

WBOY
Release: 2016-07-29 08:56:42
Original
1102 people have browsed it

通过 Last shared how to access your PHP file by writing statements in Cocos2DX to achieve the purpose of the final access to your WAMP server. So this time I will explain how to write your own php file.先 Of course, this requires you to first understand the basic grammar of PHP and the basic operation of the database in order to better realize whether your operation is correct.

                                                                                                                                                                                                                                                                                               l

$ mysql_username="root";

$mysql_password="";

$dbname="game";

$USERID=$_GET['username'];

$PASSWORD=$_GET['password'];

$open=fopen("test.xml","w");

if(empty($USERID))

{

fwrite($open,"000");

echo "user is empty" ;

}

else if(empty($PASSWORD))

{

 fwrite($open,"001");

 echo "password is empty";

}

else

{

$con=mysql_connect($mysql_server,$mysql_username,$mysql_password) ordie("Cannot connect to database");

mysql_select_db($dbname,$con);

$result=mysql_query("select * from newsuser where uname=' $USERID'and upass='$PASSWORD'");

if($row=mysql_fetch_array($result))

{

$hscore=$row['highestScore'];

fwrite($open," 11");

                                                                                                                      else

                                                                                                             

The general meaning of the entire code is to first access your own server and access your own database, enter the user name and password passed from the cocos2dx client, and then query the database for relevant information: $result=mysql_query( "select * from newsuser whereuname='$USERID' and upass='$PASSWORD'"); This statement is to query whether there is a matching username and password.登 Finally, by judging whether to log in successfully, come to the Echo statement Login Success or Login Failed.是 relatively difficult to speaking, as long as you understand the foundation, it is relatively convenient.注 Next time I share the statements of the data in the registration and modify the data in the database, and talk about the basic usage of WAMP.

The above introduces how to access the server database through php files in cocos2dx (2), including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template