search
Homephp教程php手册PHP与HTML交互

PHP与HTML交互

Jun 06, 2016 pm 07:52 PM
htmlphpinteractionPrefaceform

HTML 表单 前言: HTML HTML (HTMLtag) 。在一定程度上,Html 文档 == img 、 html 链接 a 、 html 标题 h 等等。而具体图片尺寸、标题字体则是以属性的形式提供的。 HTML 表单(用于搜集不同类型的用户输入) htmlinput向 html 页面输入数据,输入类型由类

HTML表单

前言:HTML HTML (HTML tag)。在一定程度上,Html文档==PHP与HTML交互html链接html标题等等。而具体图片尺寸、标题字体则是以属性的形式提供的。

 

HTML表单(用于搜集不同类型的用户输入)

    htmlhtml页面输入数据,输入类型由类型属性type定义。

    input

 

表单的动作属性(Action)和确认按钮

    当用户单击确认按钮时,表单的内容会被传送到另一个文件。表单的动作属性定义了目的文件的文件名。由动作属性定义的这个文件通常会对接收到的输入数据进行相关的处理。

<span style="font-size:18px;"><form name="input" action="html_form_action.asp" method="get">
    Username: <input type="text" name="user">
    <input type="submit" value="Submit">
</form></span>

    即点击submit之后,表单中的值会传到$_GET变量中去,这个变量是一个数组。文本域的name属性即是数组的键值,value就是数组中的内容


I have a bike:
I have a car:
I have an airplane:

如果您点击 "Submit" 按钮,您将把输入传送到名为 html_form_action.asp 的新页面。

                                                                     PHP与HTML交互


PHP 超全局变量 $_GET 和 $_POST 用于收集表单数据(form-data

//html代码


Name:
E-mail:

//php代码


   Welcome <?php echo $_POST["name"]; ?><br>
    Your email address is: <?php echo $_POST["email"]; ?>

_GET还是_POST

GET 和 POST 都创建数组(例如,array( key => value, key2 => value2, key3 => value3, ...))。此数组包含键/值对,其中的键是表单控件的名称,而值是来自用户的输入数据。

GET 和 POST 被视作 $_GET 和 $_POST。它们是超全局变量,这意味着对它们的访问无需考虑作用域 无需任何特殊代码,您能够从任何函数、类或文件访问它们。

$_GET 是通过 URL 参数传递到当前脚本的变量数组。(任何人可见,参数出现在url中,不安全

$_POST 是通过 HTTP POST 传递到当前脚本的变量数组。(不可见,安全)

程序员偏爱_POST

 



Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment