php登入代碼_PHP教程

來源:互聯網
上載者:User
php登入代碼這是一款完整理的php登入代碼執行個體哦,他從資料庫到html以及php程式,整個過程都一步步寫出來了,是一款非常不錯的入門級登入php代碼。

php教程登入代碼
這是一款完整理的php登入代碼執行個體哦,他從資料庫教程到html以及php程式,整個過程都一步步寫出來了,是一款非常不錯的入門級登入php代碼。
*/

session_start();

/* get post */
if (!function_exists("getpost")){function getpost(){if(count($_post)){foreach($_post as $key => $value){global ${$key};${$key}=$value;}}}}

/* get get */
if (!function_exists("getget")){function getget(){if(count($_get)){foreach($_get as $key => $value){global ${$key};$$key=($value);}}}}

/* sql escape string */
if (!function_exists("escapeit")){
function escapeit($text){
if (get_magic_quotes_gpc()) $text=strips教程lashes($text);
if (!is_numeric($text)) $text=mysql教程_real_escape_string($text);
return $text;
}}

getpost(); //擷取post過來的資料


//login

$rs = $db->query("select * from `backend_user` where binary `login` = '".escapeit($login)."' and binary `password` = '".md5($password)."'");

if (mysql_num_rows($rs) > 0) {
$row = $db->fetch_array($rs);
$_session["smartinfo_sysid"] = $row["user_id"];
$_session["smartinfo_syslogin"] = $row["login"];
$db->query("update `backend_user` set `last_logon` = '".date("y-m-d h:i:s")."' where `id` = '".$row["id"]."'");
header("location: index2.php");
} else {
header("location: index.php?status=fail");
}

//利用到的函數

?>
html代碼






control panel




資料庫

--
-- 表的結構 `backend_user`
--

create table if not exists `backend_user` (
`user_id` int(11) not null auto_increment,
`group_id` int(11) not null default '0',
`login` varchar(255) not null default '',
`password` varchar(255) not null default '',
`last_logon` datetime not null default '0000-00-00 00:00:00',
primary key (`user_id`)
) engine=myisam default charset=utf8 auto_increment=2 ;

--
-- 匯出表中的資料 `backend_user`
--

insert into `backend_user` (`user_id`, `group_id`, `login`, `password`, `last_logon`) values
(1, 0, 'admin', 'e10adc3949ba59abbe56e057f20f883e', '0000-00-00 00:00:00');

http://www.bkjia.com/PHPjc/632032.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/632032.htmlTechArticlephp登入代碼這是一款完整理的php登入代碼執行個體哦,他從資料庫到html以及php程式,整個過程都一步步寫出來了,是一款非常不錯的入門級登入...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.