PHP的一個(gè)基礎(chǔ)知識(shí) 表單提交
更新時(shí)間:2011年07月04日 22:32:48 作者:
今天在寫一個(gè)小示例的時(shí)候,就是php提交到php中的時(shí)候,把$_POST寫成$_post,結(jié)果搞了很久,還是沒有取到前臺(tái)的的值。呵呵,寫此博文,權(quán)當(dāng)積累.....下面把這個(gè)簡(jiǎn)單的例子貼一下吧!
register.php:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312">
<title>注冊(cè)頁(yè)面</title>
</head>
<body>
<form action="request.php" method="post" name="registForm">
<table width="330" border="0" align="center" cellpadding="5" bgcolor="#eeeeee">
<tr>
<td width="40%">用戶名:</td>
<td><input name="username" type="text" id="username"/></td>
</tr>
<tr>
<td>姓名:</td>
<td><input name="name" type="text" id="name"/></td>
</tr>
<tr>
<td>密碼:</td>
<td><input name="pwd" type="text" id="pwd"/></td>
</tr>
<tr>
<td>郵箱:</td>
<td><input name="email" type="text" id="email"/></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" value="提交" name="submit"/>
<input type="reset" value="重置" name="button"/>
</td>
</tr>
</table>
</form>
</body>
</html>
request.php
<?php
$username = $_POST['username'];
$name = $_POST['name'];
$pwd = $_POST['pwd'];
$email = $_POST['email'];
//print_r($username);
if(!empty($username))
{
echo "您填寫的信息為:<br>\n";
echo "用戶名: $username <br>\n";
echo "姓名: $name <br>\n";
echo "密碼: $pwd <br>\n";
echo "郵箱: $email <br>\n";
}
print_r($_POST)
//echo "aaaa";
?>
</PRE>
</DIV>
當(dāng)然,你也可以把request跟regiser.php寫到一起。
復(fù)制代碼 代碼如下:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312">
<title>注冊(cè)頁(yè)面</title>
</head>
<body>
<form action="request.php" method="post" name="registForm">
<table width="330" border="0" align="center" cellpadding="5" bgcolor="#eeeeee">
<tr>
<td width="40%">用戶名:</td>
<td><input name="username" type="text" id="username"/></td>
</tr>
<tr>
<td>姓名:</td>
<td><input name="name" type="text" id="name"/></td>
</tr>
<tr>
<td>密碼:</td>
<td><input name="pwd" type="text" id="pwd"/></td>
</tr>
<tr>
<td>郵箱:</td>
<td><input name="email" type="text" id="email"/></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" value="提交" name="submit"/>
<input type="reset" value="重置" name="button"/>
</td>
</tr>
</table>
</form>
</body>
</html>
request.php
復(fù)制代碼 代碼如下:
<?php
$username = $_POST['username'];
$name = $_POST['name'];
$pwd = $_POST['pwd'];
$email = $_POST['email'];
//print_r($username);
if(!empty($username))
{
echo "您填寫的信息為:<br>\n";
echo "用戶名: $username <br>\n";
echo "姓名: $name <br>\n";
echo "密碼: $pwd <br>\n";
echo "郵箱: $email <br>\n";
}
print_r($_POST)
//echo "aaaa";
?>
</PRE>
</DIV>
當(dāng)然,你也可以把request跟regiser.php寫到一起。
您可能感興趣的文章:
- 新手學(xué)習(xí)PHP的一些基礎(chǔ)知識(shí)分享
- php面向?qū)ο笕ヂ?(一) 面向?qū)ο蠡A(chǔ)知識(shí)
- php基礎(chǔ)知識(shí):類與對(duì)象(5) static
- php基礎(chǔ)知識(shí):類與對(duì)象(4) 范圍解析操作符(::)
- php基礎(chǔ)知識(shí):類與對(duì)象(3) 構(gòu)造函數(shù)和析構(gòu)函數(shù)
- php基礎(chǔ)知識(shí):函數(shù)基礎(chǔ)知識(shí)
- php基礎(chǔ)知識(shí):控制結(jié)構(gòu)
- PHP小白必須要知道的php基礎(chǔ)知識(shí)(超實(shí)用)
相關(guān)文章
無數(shù)據(jù)庫(kù)的詳細(xì)域名查詢程序PHP版(3)
無數(shù)據(jù)庫(kù)的詳細(xì)域名查詢程序PHP版(3)...2006-10-10
PHP數(shù)組中頭部和尾部添加元素的方法(array_unshift,array_push)
對(duì)于數(shù)字索引數(shù)組來說,通過 array_push()函數(shù)向數(shù)組中尾部添加元素,array_unshift頭部添加元素,需要的朋友可以參考下2017-04-04
PHP PDOStatement::setAttribute講解
今天小編就為大家分享一篇關(guān)于PHP PDOStatement::setAttribute講解,小編覺得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來看看吧2019-02-02
PHP個(gè)人網(wǎng)站架設(shè)連環(huán)講(四)
PHP個(gè)人網(wǎng)站架設(shè)連環(huán)講(四)...2006-10-10
PHP面向?qū)ο蟮氖褂媒坛?簡(jiǎn)單數(shù)據(jù)庫(kù)連接
PHP面向?qū)ο蟮氖褂媒坛?簡(jiǎn)單數(shù)據(jù)庫(kù)連接...2006-11-11

