Form submission (synchronous submission) and AJAX submission (asynchronous submission)

Form submission (synchronous submission)

HTML file:

 

PHP file:

In this way, you can receive the content entered in the HTML. Note:

The method of the FORM header is POST, the method of obtaining the PHP file is $_POST, the method is GET, the method of obtaining the PHP is $_GET, and the TYPE of the login (submit button) is submit

Asynchronous commit (AJAX commit)

HTML:

 PHP:

 

Notice:

FORM in HTML, the submit button TYPE is changed to BUTTON to prevent refresh. AJAX is jqery, so the script is wrapped, because I introduced the style of the pop-up window, so there is this

Here, if the data is successfully received, if the code is 1, a message will pop up, and the url will be jumped. If it is not 1, a message will pop up.

As for the PHP file, to determine whether the input data and database data are equal, two actions are performed.

Also my style is like this:

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

The writing is a bit messy, because there is no rearrangement, it may be sorted out later.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325065927&siteId=291194637