Write PHP background server POST request with subline text

Source: Internet
Author: User

1 run XAMPP program, see Apache Web Server is running status can be

2 Open subline text, create a new php file, select Save path: Application->xampp->htdocs, click Save

$_post indicates that the interface supports post requests and gets the parameters via post

3 Write code in the new PHP file, here with a simple post method to obtain login authentication, the user name is Dudu. Password 123 to login success as an example

<?php
Get login verification by post
$name = $_post["username"];
$password = $_post["password"];
Get information about valid parameters such as the Client Access server from Post
$result = Array ();
if ($name = "Dudu" && $password = "123") {
$result ["status"] = "0";
$result ["message"] = "Succeed";
} else {
$result ["status"] = "1";
$result ["message"] = "Failed";
}
Convert an array to JSON format printout
Echo (Json_encode ($result));
?>

3. Open the browser and enter http://localhost//Post.php?username=dudu&&password=123 on the URL

The results are as follows, indicating success

{"Status": "0", "message": "Succeed"}

Write PHP background server POST request with subline text

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.