php基础教程-表单.pdf
文本预览下载声明
php基础教程
一 表单 获取文本域的值
定义和用法
当用户要在表单中键入字母、数字等内容
时,就会用到文本域。
语法
textarea name test cols 25 rows 5
id test欢迎大家访问读书屋/textarea
参数说明
textarea 表示文本域,显示的内容放在中间如上例中的 “
欢迎大家访问读书屋”这一句话。
name 文本域的名称。可以自己定义名称。
cols 属性规定 textarea 的可见宽度。
rows 属性规定 textarea 的可见高度。
上面显示一个 25 个字符宽 3 行高的文本区
实例
?php
if($_POST [Submit] 提交) { //如果用户点击了提交按钮,
则获取数据
$username $_POST [username]; //取得文本框的数据
$test $_POST [test];} //取得文本域的数据
?
html
head
meta http-equiv Content-Type content text/html;
charset gb2312
title获取文本域的值--php教程网--/title
/head
body
table width 300 height 182 border 1 cellpadding 0
cellspacing 0
form name form1 method post action ?
$_SERVER[PHP_SELF] ?
tr align center
td height 30 colspan 2span class style1php教
程网留言板系统/span/td/tr
tr
td width 83 height 25 align centerspan
class style4用户名:/span/td
tdinput name username type text id username
/td /tr
tr
td align center class style4留言内容:/td
td height 50textarea name test cols 25
rows 5 id test欢迎大家访问读书屋/textarea/td
/tr
tr align center td height 25 colspan 2 input
type submit name Submit value 提交/td
/tr
tr align center
td height 25 colspan 2span class style4?php
echo $username;?/span/td
/tr
tr
td height 25 colspan 2 align centerspan
class style4?php echo $test;?/span/td
/tr
/form
/table
/body
/html
二 表单 获取复选域的值
定义和用法
当用户需要从若干给定的选择中选取一个或若干选
项时,就会用到复选框。
语法
input type checkbox name php
input type checkbox name jsp input
type checkbox name asp
参数说明
type 表单的类型。其中的checkbox表示复选框。
name 选项的名称。可以自己定义名称。
实例
?php
if($_POST [Submit] 提交) { //如果用户点击了提交按钮,则
执行下面的代码,获取用户提交的数据
$user $_POST [user];
$checkbox $_POST [checkbox]; //取得第一
显示全部