PHP form case

WBOY
Release: 2016-07-29 09:15:56
Original
1249 people have browsed it

index.php:

<code><span><span><?php</span><span>if</span> (<span>isset</span>(<span>$_POST</span>[<span>'userValue'</span>])&&!<span>empty</span>(<span>$_POST</span>[<span>'userValue'</span>])) {
  <span>echo</span><span>"您输入的是"</span>.<span>$_POST</span>[<span>'userValue'</span>];
} 
<span>else</span> {
  <span>echo</span><span>"没有接收到post值"</span>;
}
<span>?></span></span><span><!DOCTYPE html></span><span><<span>html</span><span>lang</span>=<span>"zh-CN"</span>></span><span><<span>head</span>></span><span><<span>meta</span><span>charset</span>=<span>"utf-8"</span>></span><span><<span>meta</span><span>http-equiv</span>=<span>"X-UA-Compatible"</span><span>content</span>=<span>"IE=edge"</span>></span><span><<span>meta</span><span>name</span>=<span>"viewport"</span><span>content</span>=<span>"width=device-width, initial-scale=1"</span>></span><span><!-- 上述3个meta标签*必须*放在最前面,任何其他内容都*必须*跟随其后! --></span><span><<span>title</span>></span>music<span></<span>title</span>></span><span><!-- Bootstrap --></span><span><!-- 新 Bootstrap 核心 CSS 文件 --></span><span><<span>link</span><span>rel</span>=<span>"stylesheet"</span><span>href</span>=<span>"//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css"</span>></span><span></<span>head</span>></span><span><<span>body</span>></span><span><<span>div</span><span>class</span>=<span>"container"</span>></span><span><<span>form</span><span>action</span>=<span>"<?php echo $_SERVER['PHP_SELF']; ?>"</span><span>method</span>=<span>"post"</span>><span><<span>div</span><span>class</span>=<span>"input-group input-group-lg"</span>></span><span><<span>input</span><span>type</span>=<span>"text"</span><span>class</span>=<span>"form-control"</span><span>name</span>=<span>"userValue"</span><span>placeholder</span>=<span>"传到本页面"</span>></span><span><<span>span</span><span>class</span>=<span>"input-group-btn"</span>></span><span><<span>input</span><span>type</span>=<span>"submit"</span><span>class</span>=<span>"btn btn-default"</span><span>value</span>=<span>"GO!"</span>></span><span></<span>span</span>></span><span></<span>div</span>></span><span><!-- /input-group --></span><span></<span>form</span>></span><span><<span>form</span><span>action</span>=<span>"demo.php"</span><span>method</span>=<span>"post"</span>></span><span><<span>div</span><span>class</span>=<span>"input-group input-group-lg"</span>></span><span><<span>input</span><span>type</span>=<span>"text"</span><span>class</span>=<span>"form-control"</span><span>name</span>=<span>"userValue"</span><span>placeholder</span>=<span>"传到另一个页面"</span>></span><span><<span>span</span><span>class</span>=<span>"input-group-btn"</span>></span><span><<span>input</span><span>type</span>=<span>"submit"</span><span>class</span>=<span>"btn btn-default"</span><span>value</span>=<span>"GO!"</span>></span><span></<span>span</span>></span><span></<span>div</span>></span><span><!-- /input-group --></span><span></<span>form</span>></span><span></<span>div</span>></span><span><!-- jQuery文件。务必在bootstrap.min.js 之前引入 --></span><span><<span>script</span><span>src</span>=<span>"//cdn.bootcss.com/jquery/1.11.3/jquery.min.js"</span>></span><span></span><span></<span>script</span>></span><span><!-- 最新的 Bootstrap 核心 JavaScript 文件 --></span><span><<span>script</span><span>src</span>=<span>"//cdn.bootcss.com/bootstrap/3.3.5/js/bootstrap.min.js"</span>></span><span></span><span></<span>script</span>></span><span></<span>body</span>></span><span></<span>html</span>></span></code>
Copy after login

demo.php:

<code><span><span><?php</span><span>if</span> (<span>isset</span>(<span>$_POST</span>[<span>'userValue'</span>])&&!<span>empty</span>(<span>$_POST</span>[<span>'userValue'</span>])) {
  <span>echo</span><span>"您输入的是"</span>.<span>$_POST</span>[<span>'userValue'</span>];
} 
<span>else</span> {
  <span>echo</span><span>"没有接收到post值"</span>;
}
<span>?></span></span><span><<span>meta</span><span>charset</span>=<span>"utf-8"</span>></span></code>
Copy after login

Copyright Statement: This article is an original article by the blogger and may not be reproduced without the blogger's permission.

The above has introduced the PHP form case, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

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