php 動態(tài)添加記錄
更新時(shí)間:2009年03月10日 21:15:18 作者:
php添加記錄的實(shí)現(xiàn)代碼,后面都有詳細(xì)的說明。最近的php將會讓你學(xué)到更多。
復(fù)制代碼 代碼如下:
<html>
<head>
<title>插入一條新數(shù)據(jù)</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<form method="post" name="form1" action="insert.php">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">編號:</td>
<td><input type="text" name="id" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">用戶名:</td>
<td><input type="text" name="username" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">密碼:</td>
<td><input type="text" name="password" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td colspan="2" nowrap><input name="Submit" type="submit" value="提交">
<input type="reset" name="Reset" value="重設(shè)"></td>
</tr>
</table>
</form>
</body>
</html>
復(fù)制代碼 代碼如下:
<?php
@mysql_connect("localhost", "root","1981427") //選擇數(shù)據(jù)庫之前需要先連接數(shù)據(jù)庫服務(wù)器
or die("數(shù)據(jù)庫服務(wù)器連接失敗");
@mysql_select_db("test") //選擇數(shù)據(jù)庫mydb
or die("數(shù)據(jù)庫不存在或不可用");
$id = $_POST['id'];
$username = $_POST['username'];
$password = $_POST['password'];
$query = mysql_query("insert into tablename1 values($id, '$username', '$password')");
if($query)
echo "數(shù)據(jù)插入成功";
else
echo "數(shù)據(jù)插入失敗";
mysql_close();
?>
相關(guān)文章
使用PHPMYADMIN操作mysql數(shù)據(jù)庫添加新用戶和數(shù)據(jù)庫的方法
在Mysql中創(chuàng)建多用戶,為了讓每個(gè)用戶在使用phpmyadmin管理數(shù)據(jù)庫時(shí),只能看到自己同名的數(shù)據(jù)庫,所以在設(shè)置用戶權(quán)限時(shí)要特別注意!可以參考以下步驟設(shè)置用戶權(quán)限。2010-04-04
php獲取本機(jī)真實(shí)IP地址實(shí)例代碼
這篇文章主要為大家詳細(xì)介紹了php獲取本機(jī)真實(shí)IP地址實(shí)例代碼,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-03-03
php iconv() : Detected an illegal character in input string
PHP傳給JS字符串用ecsape轉(zhuǎn)換加到url里,又用PHP接收,再用網(wǎng)上找的unscape函數(shù)轉(zhuǎn)換一下,這樣得到的字符串是UTF-8的,但我需要的是GB2312,于是用iconv轉(zhuǎn)換2010-12-12
PHP根據(jù)文章內(nèi)容生成關(guān)鍵詞自動化Keywords標(biāo)簽
這篇文章主要為大家介紹了PHP根據(jù)文章內(nèi)容生成關(guān)鍵詞實(shí)現(xiàn)自動化Keywords標(biāo)簽實(shí)例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-12-12

