API Interface Login

Source: Internet
Author: User

The use of PHP to connect the MySQL database to achieve a simple user login registration and modify the Password API interface, the interface for the standard JSON output, local validation through. function is relatively simple, but also their own groping for a long time, a variety of Baidu to solve a variety of do not understand. The database has only the name, PSD, and Tel three fields, and the interface is designed for post submission. The code basically has the annotation to be better understood, the following enclose the code.

[PHP]  View plain  copy <?php        $mysql _server_name= "localhost";  // Database server name         $mysql _username= "root"; //  connection database user name          $mysql _password= "326699"; //  Connection Database Password         $mysql _ database= "Hello"; //  database name                 //  Connect to database         $conn =mysql_connect ($mysql _server_name,  $mysql _ username,                             $mysql _password);        if (! $conn)  {           echo  database connection failed. ".mysql_error;       }       mysql_select_db ($mysql _ database,  $conn);              //Get URL parameters          $action  = isset ($_post[' action ')]  ? $_post[' action '] :  ';         $name  = isset ($_post[' name ')  ? $_post[' name '] :  ' ';        $psd  = isset ($_post[' PSD '])  ? $_post[' psd ']    ';              if ($action = = ' Login ')  {            login ($name,  $psd,  true);       } else if ($action = = ' register ')  {            register ($name,  $psd);       } else if ($ action== ' modifypsd ')  {           modifypsd ($name,  $ PSD);      } else if ($action = = ' ShowAll ')  {            showall ();       } else {             $result  = array ("result" => "error_request");            $json  = json_encode ($result);            echo  $json;       }              close_conn ();               /* User Login */       function login ($name,   $PSD

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.