PHP development API interface registration, login, query user information

Source: Internet
Author: User
PHP development API interface registration, login, query User Information Server & lt ;? Phprequireconn. php; header (Content-Type: texthtml; charsetutf-8); $ action $ _ GET [action]; switch ($ action) {Register member case & quot PHP development API interface registration, log on to and query user information

Server

 0) {exit (json_encode (1); // return 1 indicates registration failed} else {$ addsql = "insert into 'member' (username, password, email) values ('$ username',' $ password', '$ email') "; mysql_query ($ addsql); exit (json_encode (0 )); // return 0 indicating successful registration} break; // query User information case "selectuserinfo"; $ username = lib_replace_end_tag ($ _ GET ['username']); $ SQL = "select id, username, nickname, mobile from 'member' where username = '$ username'"; $ query = mysql_qu Ery ($ SQL, $ conn); $ row = mysql_fetch_array ($ query); foreach ($ row as $ key => $ v) {$ res [$ key] = urlencode ($ v);} exit (json_encode ($ res); break; // member logon case "userlogin "; $ username = lib_replace_end_tag ($ _ GET ['username']); $ password2 = lib_replace_end_tag (trim ($ _ GET ['userpassword']); $ password = md5 ("$ password2 ". ALL_PS); $ sqluser = "select id, username, password from 'member' where username = '". $ u Sername. "'and password = '". $ password. "'"; $ queryuser = mysql_query ($ sqluser); $ rowuser = mysql_fetch_array ($ queryuser); if ($ rowuser & is_array ($ rowuser )&&! Empty ($ rowuser) {if ($ rowuser ['username'] = $ username & $ rowuser ['password'] = $ password) {if ($ rowuser ['password'] = $ password) {$ res = urlencode ("logon successful"); exit (json_encode ($ res ));} else {$ res = urlencode ("incorrect password"); exit (json_encode ($ res) ;}} else {$ res = urlencode ("the user name does not exist "); exit (json_encode ($ res) ;}} else {$ res = urlencode ("incorrect user name and password"); exit (json_encode ($ res);}/** 0: indicates that the logon is successful. 1: indicates that the password is incorrect. Error: 2: The user name does not exist; 3: The user name and password are incorrect */break; default: exit (json_encode (error);}?>

Client example:

 


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.