首頁 >後端開發 >php教程 >PHP表單案例

PHP表單案例

WBOY
WBOY原創
2016-07-29 09:15:561241瀏覽

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>

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>

版權聲明:本文為部落客原創文章,未經部落客允許不得轉載。

以上就介紹了PHP表單案例,包含了方面的內容,希望對PHP教學有興趣的朋友有幫助。

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
上一篇:osx中安裝gpg下一篇:osx中安裝gpg