PHP的一個基礎知識

今天在寫一個小示例的時候,就是php提交到php中的時候,把$_POST寫成$_post,結果搞了很久,還是沒有取到前臺的的值。呵呵,寫此博文,權當積累.....下面把這個簡單的例子貼一下吧!
register.php:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312">
<title>註冊頁面</title>
</head>
<body>
<form action="register1.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>

register1.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);//這裏是測試你從頁面到底封裝了那些數據
?>

當然,你也可以把regiser1.php跟regiser.php寫到一起。
發佈了41 篇原創文章 · 獲贊 3 · 訪問量 1萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章