前言
这篇笔记记录的是web表单的相关操作,web表单主要用来在网页中发送数据到服务器。比如在日常开发中,提交注册时需要提交表单,表单从客户端传送到服务器,经过服务器处理后,再将用户所需要的信息传递回客户端,进而实现php与web表单的交互。
相关学习推荐:php编程(视频)
表单
使用<form>元素,并在其中插入相关的表单元素,即可创建一个表单。表单结构:<form name="form_name" method="method" action="url" enctype="value" target="target_win">… //省略插入的表单元素</form >form标记的属性如下表:
form标记的属性说明name表单名称method设置表单的提交方式,get或者post方法action纸箱处理该表单页面的urlenctype设置表单内容的编码方式target设置返回信息的显示方式
表单(form)由表单元素组成。常用的表单元素有以下几种标记:输入域标记<input>、选择域标记<select>和<option>、文字域标记<textarea>等。输入域标记<input>
输入域标记<input>是表单中最常用的标记之一。常用的文本框、按钮、单选按钮、复选框等构成了一个完整的表单。
语法格式如下:
<form><input name="file_name" type="type_name"></form>参数name是指输入域的名称,参数type是指输入域的类型。在<input type="">标记中一共提供了10种类型的输入区域,用户所选择使用的类型由type属性决定。
下面举几个type属性例子:
1、text
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="content-type" content="text/html; charset=gb2312" /><title>php语言基础</title></head><body><form action="index.php" method="post" name="form1" enctype="multipart/form-data"> <tr bgcolor="#ffcc33"> <td width="103" height="25" align="right">文本框:</td> <td height="25" align="left"><input name="user" type="text" value="bill" id="user" size="20" maxlength="100"></td> </tr></form><?phpheader("content-type:text/html; charset=gb2312");?></body></html>运行效果:
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="content-type" content="text/html; charset=gb2312" /><title>php语言基础</title></head><body><form action="index.php" method="post" name="form1" enctype="multipart/form-data"> <tr bgcolor="#ffcc33"> <td width="103" height="25" align="right">密码域:</td> <td height="25" align="left"> <input name="pwd" type="password" value="1234567" id="password" size="20" maxlength="100"> </td> </tr></form><?phpheader("content-type:text/html; charset=gb2312");?></body></html>运行结果:
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="content-type" content="text/html; charset=gb2312" /><title>php语言基础</title></head><body><form action="index.php" method="post" name="form1" enctype="multipart/form-data"> <tr bgcolor="#ffcc33"> <td width="103" height="25" align="right">文件域:</td> <td height="25" align="left"> <input name="file" type="file" enctype="multipart/form-data" id="upfile" size="20" maxlength="200"> </td> </tr></form><?phpheader("content-type:text/html; charset=gb2312");?></body></html>运行结果:
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://
域名无法打开-域名及账户问题电脑中玩反恐精英ol2掉线如何解决 为什么玩反恐精英OL老是掉线什么是优质域名,优质域名抢注的价值Linux输入输出重定向的介绍魔影工厂怎么剪辑视频 魔影工厂剪辑视频的方法买了个云服务器PS画笔变成十字箭头怎么改成圆(改成圆的使用教程)这个空间客户反映说根目录下面的有个目录不见了