PHP表单案例

WBOY
Lepaskan: 2016-07-29 09:15:56
asal
1273 orang telah melayarinya

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><span>html</span><span>lang</span>=<span>"zh-CN"</span>></span><span>head</span>></span><span>meta</span><span>charset</span>=<span>"utf-8"</span>><span>meta</span><span>http-equiv</span>=<span>"X-UA-Compatible"</span><span>content</span>=<span>"IE=edge"</span>><span>meta</span><span>name</span>=<span>"viewport"</span><span>content</span>=<span>"width=device-width, initial-scale=1"</span>><span><!-- 上述3个meta标签*必须*放在最前面,任何其他内容都*必须*跟随其后! --></span><span>title</span>>music<span><span>title</span>></span><span><!-- Bootstrap --></span><span><!-- 新 Bootstrap 核心 CSS 文件 --></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>head</span>></span><span>body</span>><span>div</span><span>class</span>=<span>"container"</span>><span>form</span><span>action</span>=<span>"<?php echo $_SERVER['PHP_SELF']; ?>"</span><span>method</span>=<span>"post"</span>><span>div</span><span>class</span>=<span>"input-group input-group-lg"</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>class</span>=<span>"input-group-btn"</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>div</span>></span><span><!-- /input-group --></span><span><span>form</span>></span><span>form</span><span>action</span>=<span>"demo.php"</span><span>method</span>=<span>"post"</span>><span>div</span><span>class</span>=<span>"input-group input-group-lg"</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>class</span>=<span>"input-group-btn"</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>div</span>></span><span><!-- /input-group --></span><span><span>form</span>></span><span><span>div</span>></span><span><!-- jQuery文件。务必在bootstrap.min.js 之前引入 --></span><span>script</span><span>src</span>=<span>"//cdn.bootcss.com/jquery/1.11.3/jquery.min.js"</span>><span></span><span><span>script</span>></span><span><!-- 最新的 Bootstrap 核心 JavaScript 文件 --></span><span>script</span><span>src</span>=<span>"//cdn.bootcss.com/bootstrap/3.3.5/js/bootstrap.min.js"</span>><span></span><span><span>script</span>></span><span><span>body</span>></span><span><span>html</span>></span></code>
Salin selepas log masuk

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>meta</span><span>charset</span>=<span>"utf-8"</span>></span></code>
Salin selepas log masuk

版权声明:本文为博主原创文章,未经博主允许不得转载。

以上就介绍了PHP表单案例,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

Label berkaitan:
sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan