background image

php 获取文本框中值的实现代码

本文介绍下,在

php 中获取文本框中的值的一段代码,有需要的朋友,可以作为参考。

先来看下表单的用法,如下:
代码示例

:

<form name="form" method="post" action="login.php"></form>
文本框的用法:
代码示例

:

<input type="text" name="username" />
其中

input 类型包括 text、password 等类型。

填入表单提交后:
代码示例

:

<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>