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í)這類的知識可以很好的了解一下,因為分的越細,用的越方便。
看看本實例的功能
<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í)這類的知識可以很好的了解一下,因為分的越細,用的越方便。
看看本實例的功能
填入表單提交后:
實現(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)文章
不用數(shù)據(jù)庫的多用戶文件自由上傳投票系統(tǒng)(2)
不用數(shù)據(jù)庫的多用戶文件自由上傳投票系統(tǒng)(2)...2006-10-10PHP中number_format()函數(shù)的用法講解
今天小編就為大家分享一篇關(guān)于PHP中number_format()函數(shù)的用法講解,小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧2019-04-04php基礎(chǔ)教程 php內(nèi)置函數(shù)實例教程
其實這些內(nèi)容在php手冊就可以學(xué)習(xí)的 但是很多php入門初學(xué)者對php手冊不知道怎么看 看也看不懂2012-08-08