Fulfillment of PHPRPCforphp login

Source: Internet
Author: User
The implementation of PHPRPCforphp login has always wanted to study what the webservice under php looks like. I finally took time out today. I found this phprpc on the Internet to block webservice under php. It also supports other versions. Here, I will only mention the small application of phprpcforphp. if you are interested, you can go to the official website to learn about the implementation of login to other versions of the official website: www.phprpc.org PHPRPC for php.
I have been wondering what the web service under php looks like. I finally took time out today. I found this phprpc on the Internet and closed the web service in php. It also supports other versions. Here, I will only mention
Phprpc for php is a small application. if you are interested, go to the official website to learn about other versions.
Official website: http://www.phprpc.org/zh_CN/

First, simply download phprpc_3.0.20.php.zip and extract the files.
Dhparams // folder pecl // folder bigint. phpcompat. phpphprpc_date.phpdhparams.phpphprpc_server.phpphprpc_client.phpxxtea.php

The following files are public files, both on the server side and on the client side.
bigint.phpcompat.phpphprpc_date.phpxxtea.php

The following are the files required by the server.
dhparamsdhparams.phpphprpc_server.phpbigint.phpcompat.phpphprpc_date.phpxxtea.php

Which of the following is required by the client?
phprpc_client.phpbigint.phpcompat.phpphprpc_date.phpxxtea.php

First, create two folders under the www Directory
Webservice
Webclient
Put the server file into webservice
Store client files in webclient

Create a test. php file in webservice.
The code is as follows:
Include ('phprpc_server. php '); function islogin ($ u, $ p) {$ con = mysql_connect ('localhost', 'root', '123 ') or die ('database connection failed'); mysql_select_db ('newspublish '); mysql_query ('set NAMES utf8'); $ p = md5 ($ p ); $ SQL = "select * from t_user where 'username' = '$ u' and 'password' =' $ P'"; // file_put_contents('log.txt ', $ SQL ); $ result = mysql_query ($ SQL); $ n = mysql_num_rows ($ result); if ($ n> 0) {return true;} else {return false ;}} function login ($ u, $ p) {if (islogin ($ u, $ p) {return true;} else {return false ;}/// the above code, I will not talk about it much. for php users, the basics are $ server = new PHPRPC_Server (); $ server-> add ('login '); // add a method to allow remote access $ server-> setDebugMode (true); // enable the debugging mode, but I don't know how to use this, $ server-> start (); // start

Create a client. php file in webclient
Then read the client code
 Login ('lxx', 'test') {echo "Login Success! ";} Else {echo" Login Wrong! ";}?>

Then access http: // localhost/webclient/client. php in the address bar.
Let's see the effect.

Is it easy! Here is just some simple verification. for data reading and writing, this has not been studied yet,
If there is any result, it will be updated immediately. if you like it, you can follow it.

Also, note that if you find that the results are different from what you want without any prompts, go to the server to find an error. Although the debugging mode is enabled, but I don't know how to use it. some code lines have errors and the client does not prompt!

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.