PHP篇

WBOY
Release: 2016-06-23 14:37:10
Original
1064 people have browsed it

*持续更新中

 

1. 表单元素的获取

PHP中获取表单元素的方法较为简单、纯净、易于理解,跟ASP.NET差别很大,我们新建一个页面Index.php用于递交表单:

<form id="formMain" action="Action.php" method="post">	<input name="txtName" type="text" /><br />	<input name="txtAge" type="text" /><br />	<input name="btnSumbit" type="submit" value="Submit" /></form>
Copy after login

注意页面中的text元素用name标识,若写成id则无法获取,在Action.php中获取表单中的值,并打印出来:

Your name: <?php echo $_POST["txtName"]; ?><br />Your age: <?php echo $_POST["txtAge"] ?>
Copy after login

这里使用了$_POST[“”],填入表单元素的name即可获取该元素的值。

$_POST中存放了post方式提交的数据,若为get方式则用$_GET,若不关心来源也可使用$_REQUEST,它其中包含了get、post、cookie和file的数据。

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template