PHP程序開發(fā)范例學(xué)習(xí)之表單 獲取文本框的值
更新時間:2011年08月08日 18:53:04 作者:
表單在網(wǎng)站中的應(yīng)用可以說是網(wǎng)站的根基,幾乎沒有不用表單的網(wǎng)站,還是先回顧一下表單的用法吧
<form name="form" method="post" action="login.php"></form>
文本框的用法:
<input type="text" name="username" />
其中input類型包括text、password等類型,HTML5新增了很多的input類型,如果想學(xué)習(xí)這類的知識可以很好的了解一下,因為分的越細(xì),用的越方便。
看看本實例的功能
<table width="283" height="85" border="1" cellpadding="0" cellspacing="0">
<form name="name1" method="post" action="abc.php">
<tr>
<td width="114" height="30" align="center" >管理員:</td>
<td width="163" height="30" align="center"><input name="username" type="text" /></td>
</tr>
<tr>
<td align="center">密 碼:</td>
<td height="30" align="center"><input name="password" type="password" /></td>
</tr>
<tr>
<td> </td>
<td height="25"> <input name="submit" type="submit" value="submit" /></td>
</tr>
</form>
</table>
<?php
if(!isset($_POST['submit']))
return ;
if($_POST['submit']=='submit'){
$username = $_POST['username'];
$password = $_POST['password'];
}
echo <<<EOT
<table width="284" border="1" cellpadding="0" cellspacing="0">
<tr>
<td height="25" align="center"> 管理員:$username</td>
</tr>
<tr>
<td height="25" align="center" valign="middle" class="style2">密碼:$password</td>
</tr>
</table>
EOT;
?>
使用 isset()函數(shù)判斷$_POST['submit']是否被設(shè)置
文本框的用法:
<input type="text" name="username" />
其中input類型包括text、password等類型,HTML5新增了很多的input類型,如果想學(xué)習(xí)這類的知識可以很好的了解一下,因為分的越細(xì),用的越方便。
看看本實例的功能

填入表單提交后:

實現(xiàn)代碼:
復(fù)制代碼 代碼如下:
<table width="283" height="85" border="1" cellpadding="0" cellspacing="0">
<form name="name1" method="post" action="abc.php">
<tr>
<td width="114" height="30" align="center" >管理員:</td>
<td width="163" height="30" align="center"><input name="username" type="text" /></td>
</tr>
<tr>
<td align="center">密 碼:</td>
<td height="30" align="center"><input name="password" type="password" /></td>
</tr>
<tr>
<td> </td>
<td height="25"> <input name="submit" type="submit" value="submit" /></td>
</tr>
</form>
</table>
<?php
if(!isset($_POST['submit']))
return ;
if($_POST['submit']=='submit'){
$username = $_POST['username'];
$password = $_POST['password'];
}
echo <<<EOT
<table width="284" border="1" cellpadding="0" cellspacing="0">
<tr>
<td height="25" align="center"> 管理員:$username</td>
</tr>
<tr>
<td height="25" align="center" valign="middle" class="style2">密碼:$password</td>
</tr>
</table>
EOT;
?>
使用 isset()函數(shù)判斷$_POST['submit']是否被設(shè)置
相關(guān)文章
通過ICQ網(wǎng)關(guān)發(fā)送手機短信的PHP源程序
通過ICQ網(wǎng)關(guān)發(fā)送手機短信的PHP源程序...2006-10-10
Linux下 php5 MySQL5 Apache2 phpMyAdmin ZendOptimizer安裝與配置[圖文]
很久就想出這個配置教程了.最近忙實習(xí)又忙畢業(yè)論文.一直沒用時間.但看到很多人需要這個教程. 所以還是決定抽一天時間出來.linux下的php環(huán)境配置要比windows下的麻煩得多.特別是源碼安裝的.2008-11-11
使用函數(shù)遞歸實現(xiàn)基于php和MySQL的動態(tài)樹型菜單
使用函數(shù)遞歸實現(xiàn)基于php和MySQL的動態(tài)樹型菜單...2006-10-10
php header Content-Type類型小結(jié)
php header Content-Type類型小結(jié),很多情況下需要用到Content-Type類型。2011-07-07
不用iconv庫的gb2312與utf-8的互換函數(shù)
不用iconv庫的gb2312與utf-8的互換函數(shù)...2006-10-10

