Getting Started with PHP

Source: Internet
Author: User
Tags getting started with php urlencode

Getting Started with PHP

PHP provides two ways to interact with Web pages

    1. Submit data through a Web Form

    2. Passing through URL parameters

Let's start with the following interaction with a Web page through a form

<form name= "" method= "Post|get" action= "url" ></form>

Forms are submitted in two types of post get, specified by Form method

Post: A handler that sends the data in the form as a block of data to the server. This method is more secure, the data is appended to the header information, the user can not be arbitrarily modified.

Get: Attaches the form's data to the back of the URL and is simple and intuitive. Default mode

Http://url?name1=value1&name2=value2&name3=value3

So, how does PHP get the data submitted by the form?

Using Post to submit via $_get and $_post array form data is received using _$post data, and submission using the GET method is done with the $_get method. For example

Index.html<form name= "Form1" method= "Post" action= "index.php" > <label for= "username" >username</ label> <input type= "text" name= "user" id= "username" > <input type= "Submit" name= "submit" value= "Submit" >&L T;/form>//index.php<?phpif ($_post["Submit"]!=null) {echo $_post["user"];} else{echo "username is null";}

Note: When submitting data using $_post or $_get data, the index string value must be the same as the value of the form name. This is the only way to get the value of the form submission correctly

==============================================================

Encode and decode the data passed by the URL

Because the pass parameter is passed using a URL, the value of the parameter is appended directly to the URL, which is not secure. So consider using a function to encode a parameter, which can be passed by using string UrlEncode (String str) without exposing it to the back of the URL

For example

<a href= "index.php?name=<?php Echo urlencode (" Wang Xiaoming ")?>" >name</a>/* was tested to find that English could not be encoded and encoded on IE, But not in the Sogou browser */

Manuscripts: Diligent Learning qkxue.net

Extended reading:

Getting Started with PHP (7) PHP interacts with web pages
Http://qkxue.net/info/26892/PHP-PHP-Web-7
Getting Started with PHP (8) PHP interacts with JavaScript
Http://qkxue.net/info/26900/PHP-PHP-JavaScript-8
Getting Started with PHP (9) Cookies and session
Http://qkxue.net/info/27702/PHP-Cookie-Session-9

Getting Started with PHP

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.