http://www.hkcode.com/programming/242
http://www.php5.idv.tw/modules.php?mod=forum&act=show&cid=13&showid=1931
新增資料
CODE:
<?php
$db_conn = mysql_connect("host", "db_user", "db_pass");
mysql_select_db("db_name", $db_conn);
// 插入資料表的 $password 用了 md5 加密
mysql_query("insert into users values
('$username', '".md5($password)."')");
?>
查詢帳號
CODE:
<?php
$db_conn = mysql_connect("host", "db_user", "db_pass");
mysql_select_db("db_name", $db_conn);
$sql = mysql_query("select * from users where
`username`='$username' and
`password`='".md5($password)."'");
if (mysql_num_rows($sql) > 0) {
// 用戶名稱及密碼正確
} else {
// 用戶名稱及密碼錯誤
exit();
}
?>
沒有留言:
張貼留言