PHP Development API Interface Registration, login, query user information

Source: Internet
Author: User
Tags http post urlencode
PHP Development API Interface Registration, login, query user information

Service side

  0) {exit (Json_encode (1));//return 1 means registration failed} else {$addsql = "insert INTO ' member ' (USERNAME,PA            Ssword,email) VALUES (' $username ', ' $password ', ' $email ');            mysql_query ($addsql); Exit (Json_encode (0));    Returns 0 for registration success} 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_query ($sql, $conn);        $row = Mysql_fetch_array ($query);        foreach ($row as $key = = $v) {$res [$key] = UrlEncode ($v);        } exit (Json_encode ($res));    Break        Member Login Case "Userlogin";        $username = Lib_replace_end_tag ($_get[' username ');        $password 2 = Lib_replace_end_tag (Trim ($_get[' userpassword ')); $password = MD5 ("$password 2".        ALL_PS); $sqluser = "Select Id,username,password from ' member ' where Username= '". $username. "' 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 ("Login Successful");                Exit (Json_encode ($res));                    } else {$res = UrlEncode ("Bad password");                Exit (Json_encode ($res));                }} else {$res = UrlEncode ("User name does not exist");            Exit (Json_encode ($res));            }} else {$res = UrlEncode ("User name password error");        Exit (Json_encode ($res));    }/* * 0: Indicates successful login, 1: Password error, 2: User name does not exist, 3: User name password error */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.