PHP CB Training
PHP CB Training
SITE GM C:
Folder include: config.php,
top.php, left.php, bottom.php,
nicEdit.js (b son tho vn bn).
Folder admin: index_admin.php, login.php, logout.php,
add_cate.php, edit_cate.php, del_cate.php, mana_cate.php,
add_news.php, edit_news.php, del_news.php, mana_news.php,
add_user.php, edit_user.php, del_user.php, mana_user.php.
Folder data: folder news/ cc hnh upload.
Folder database: folder project/ cc database, table.
Folder images: cc hnh upload.
!ndex.php
"eadnews.php
#iewcate.php
config.php
$%
header&'(ontent)t*pe: text/html+ charset,utf)-')+
session_start&)+
session_register&'userid')+
session_register&'username')+
session_register&'le.el')+
///han nguoi dung chinh sua thong tin (012
3host, 'localhost'+
3user, 'root'+
3pass, 'root'+
3db, 'project'+
///han 4et noi co so du lieu.
3connect, m*s5l_connect&3host,3user,3pass) or die&'(an6t connect 1atabase')+
m*s5l_select_db&3db,3connect)+
%7
top.php
$%
re5uire&'include/config.php')+
%7
$819(:;/E html /<=2!( ')//>?(//1:1 @A:B2 C.D :ransitional//EE'
'http://www.w?.org/:"/xhtmlC/1:1/xhtmlC)transitional.dtd'7
$html xmlns,'http://www.w?.org/CFFF/xhtml'7
$head7
$meta http)e5ui.,'(ontent):*pe' content,'text/html+ charset,utf)-' /7
$lin4 href,'images/st*le.css' rel,'st*lesheet' t*pe,'text/css' /7
$title7<ntitled 1ocument$/title7
$/head7
$bod*7
$di. id,main7
$di. id,top7=anner
$/di.7
left.php
$di. id,content7
$di. id,left7
$hC7:rang (hGHI?J+nh$/hC7
$ul7
$li7$a href,'index.php'7:rang (hGHJFCC+$/a7$/li7
$/ul7
$hC7(hu*GHI?K+n BGHJFDF+c$/hC7
$ul7
PHP cn bn 1
$%
3s5l,'select L from cate_news order b* cate_news_title'+
35uer*,m*s5l_5uer*&3s5l)+
while&3row,m*s5l_fetch_arra*&35uer*))
M
echo '$li7$a href,6.iewcate.php%cateid,3rowNcate_news_idO673rowNcate_news_titleO$/a7$/li7'+
P
%7
$/ul7
$/di.7
botto.php
$/di.7
$di. id,bottom7(op*right
$/di.7
$/di.7
$/bod*7
$/html7
in!e"#$!in.php
$%
re5uire&'../include/config.php')+
if&isset&3_0E00!9EN6userid6O) G 3_0E00!9EN6le.el6O ,, I)
M
%7
$html7
$head7 $/head7
$bod* st*le,'font)famil*:arial + font)siQe:CDpx+'7
$table align,center width,RDD height,SDD .align,top border,C7
$tr7$td colspan,'I' align,center height,SD7>elcome to, Tdmin$/td7$/tr7
$tr7
$td .align,top width,CRD7$span st*le,'font)weight:FDD+ bac4ground:Ureen+ color:white+
width:CRDpx+ text)align:center'7Benu$/span7$br /7 $br /7
$p7
$ul t*pe,s5uare7
$li7$a href,'add_cate.php'7Tdd (ategories$/a7$/li7
$li7$a href,'mana_cate.php'7Banage (ategories$/a7$/li7
$li7$a href,'add_news.php'7Tdd Eews$/a7$/li7
$li7$a href,'mana_news.php'7Banage Eews$/a7$/li7
$li7$a href,add_user.php7Tdd <ser$/a7$/li7
$li7$a href,mana_user.php7Banager <ser$/a7$/li7
$li7$a href,'logout.php'72ogout$/a7$/li7
$/ul7
$/td7
$td .align,top7 (ontent $/td7
$/tr7
$/table7
$/bod*7
$/html7
$%
P
else
M
header&'location:login.php')+
exit&)+
P
%7
login.php
$%
re5uire&'../include/config.php')+
if&isset&3_/90:N6login6O))
M
PHP cn bn %
if&3_/90:N6username6O ,, E<22)
M
echo '/lease enter *our username$br /7'+
P
else
M
3u, 3_/90:N6username6O+
P
if&3_/90:N6password6O ,, E<22)
M
echo '/lease enter *our password$br /7'+
P
else
M
3p, 3_/90:N6password6O+
P
if&3u G 3p)
M
3s5l,'select L from user where username,6'.3u.'6 and password,6'.mdS&3p).'6'+
35uer*,m*s5l_5uer*&3s5l)+
if&m*s5l_num_rows&35uer*) ,, '')
M
echo ';our username or password is not correct'+
P
else
M
3row,m*s5l_fetch_arra*&35uer*)+
3_0E00!9EN6userid6O, 3rowNidO+
3_0E00!9EN6username6O, 3rowNusernameO+
3_0E00!9EN6le.el6O, 3rowNle.elO+
header&'location:index.php')+
exit&)+
P
P
P
%7
$form action,'login.php' method,/90:7
<sername: $input t*pe,text name,username siQe,IS /7$br /7
/assword: $input t*pe,password name,password siQe,IS /7 $br /7
$input t*pe,submit name,'login' .alue, '2ogin'7
$/form7
logo&t.php
$%
re5uire&'../include/config.php')+
session_destro*&)+
header&'location:login.php')+
exit&)+
%7
$!!#c$te.php
$%
re5uire&'../include/config.php')+
if&isset&3_/90:N6addcate6O))
M
if&3_/90:N6title6O ,, E<22)
M
echo '/lease enter *our categories Eame'+
P
else
M
3t,3_/90:N6title6O+
P
if&3t)
M
PHP cn bn '
3s5l,'insert into cate_news&cate_news_title) .alues&6'.3t.'6)'+
35uer*,m*s5l_5uer*&3s5l)+
header&'location:mana_cate.php')+
exit&)+
P
P
%7
$form action,'add_cate.php' method,'post'7
(ategories Eame : $input t*pe,text name,title siQe,IS /7
$input t*pe,submit name,addcate .alue,'Tdd Eew (ategories'7
$/form7
e!it#c$te.php
$%
re5uire&'../include/config.php')+
3id,3_UE:N6cateid6O+
if&isset&3_/90:N6editcate6O))
M
if&3_/90:N6title6O ,, E<22)
M
echo '/lease enter *our categorie news'+
P
else
M
3t, 3_/90:N6title6O+
P
if&3t)
M
3s5l,'update cate_news set cate_news_title,6'.3t.'6 where cate_news_id,6'.3id.'6'+
35uer*,m*s5l_5uer*&3s5l)+
header&'location:mana_cate.php')+
exit&)+
P
P
3s5l,'select L from cate_news where cate_news_id,6'.3id.'6'+
35uer*,m*s5l_5uer*&3s5l)+
3row,m*s5l_fetch_arra*&35uer*)+
//su dung cu phap $%,3tenbien%7 de goi bien ngan gon trong A:B2
%7
$form action,edit_cate.php%cateid,$%,3id%7 method,/90:7
(ategories Eame $input t*pe,text name,title siQe,IS .alue,'$%,3rowNcate_news_titleO%7'7
$input t*pe,submit name,editcate .alue,'Edit (ategorie'7
$/form7
e!it#c$te#c%.php
$%
re5uire&'../include/config.php')+
session_register&6cateid6)+
3id,3_UE:N6cateid6O+
if&isset&3_/90:N6editcate6O))
M
if&3_/90:N6title6O ,, E<22)
M
echo '/lease enter *our categorie news'+
P
else
M
3t, 3_/90:N6title6O+
P
if&3t)
M
3s5l,'update cate_news set cate_news_title,6'.3t.'6 where
cate_news_id,6'.3_0E00!9EN6cateid6O.'6'+
35uer*,m*s5l_5uer*&3s5l)+
session_unregister&6cateid6)+
header&'location:mana_cate.php')+
PHP cn bn (
exit&)+
P
P
3s5l,'select L from cate_news where cate_news_id,6'.3id.'6'+
35uer*,m*s5l_5uer*&3s5l)+
3row,m*s5l_fetch_arra*&35uer*)+
3_0E00!9EN6cateid6O , 3id+
//su dung cu phap $%,3tenbien%7 de goi bien ngan gon trong A:B2
%7
$form action,edit_cate.php method,/90:7
(ategories Eame $input t*pe,text name,title siQe,IS .alue,'$%,3rowNcate_news_titleO%7'7
$input t*pe,submit name,editcate .alue,'Edit (ategorie'7
$/form7
!el#c$te.php
$%
re5uire&'../include/config.php')+
3id,3_UE:N6cateid6O+
3s5l,'delete from cate_news where cate_news_id,6'.3id.'6 '+
35uer*,m*s5l_5uer*&3s5l)+
header&'location:mana_cate.php')+
exit&)+
%7
$n$#c$te.php
$%
re5uire&'../include/config.php')+
%7
$p align,center7 $a href,add_cate.php7Tdd Eew categories$/a7$/p7
$table align,center width,KDD border,C7
$tr7
$td70::$/td7
$td7Eame$/td7
$td7Edit$/td7
$td71el$/td7
$/tr7
$%
3s5l,'select L from cate_news order b* cate_news_id desc'+
35uer*,m*s5l_5uer*&3s5l)+
if&m*s5l_num_rows&35uer*) ,, '')
M
echo '$tr7$td colspan,K7 (hua co du lieu$/td7$/tr7'+
P
else
M
3stt,D+
while&3row,m*s5l_fetch_arra*&35uer*))
M
3sttVV+
echo '$tr7'+
echo '$td73stt$/td7'+
echo '$td73rowNcate_news_titleO$/td7'+
echo '$td7$a href,edit_cate.php%cateid,3rowNcate_news_idO7Edit$/a7$/td7'+
echo '$td7$a href,del_cate.php%cateid,3rowNcate_news_idO71el$/a7$/td7'+
echo '$/tr7'+
P
P
%7
$/table7
$!!#ne)*.php
$%
re5uire&'../include/config.php')+
if&isset&3_/90:N6addnews6O))
M
PHP cn bn +
if&3_/90:N6title6O ,, E<22)
M
echo '/lease enter *our title'+
P
else
M
3t,3_/90:N6title6O+
P
if&3_/90:N6author6O ,, E<22)
M
echo '/lease enter *our author'+
P
else
M
3a,3_/90:N6author6O+
P
if&3_/90:N6info6O ,, E<22)
M
echo '/lease enter *our !nformation'+
P
else
M
3i,3_/90:N6info6O+
P
if&3_/90:N6full6O ,, E<22)
M
echo '/lease enter *our Full Eews'+
P
else
M
3f,3_/90:N6full6O+
P
if&3_F!2E0N6img6ON6name6O 8, E<22)
M
mo.e_uploaded_file&3_F!2E0N6img6ON6tmp_name6O, '../data/news/'.3_F!2E0N6img6ON6name6O)+
3image, 'data/news/'.3_F!2E0N6img6ON6name6O+
P
3cate,3_/90:N6categories6O+
3chc,3_/90:N6chec46O+
if&3t G 3a G 3i G 3f G 3image G 3cate G 3chc)
M
3s5l,'insert into news&news_title, news_author, news_info, news_full, news_img,
cate_news_id,news_chec4) .alues&6'.3t.'6,6'.3a.'6,6'.3i.'6,6'.3f.'6,6'.3image.'6,6'.3cate.'6,6'.3chc.'6)'+
35uer*,m*s5l_5uer*&3s5l)+
header&'location: mana_news.php')+
exit&)+
P
else
M
if&3t G 3a G 3i G 3f G 3cate G 3chc)
M
3s5l,'insert into news&news_title, news_author, news_info, news_full,
cate_news_id,news_chec4) .alues&6'.3t.'6,6'.3a.'6,6'.3i.'6,6'.3f.'6,6'.3cate.'6,6'.3chc.'6)'+
35uer*,m*s5l_5uer*&3s5l)+
header&'location: mana_news.php')+
exit&)+
P
P
P
%7
$script language,'Wa.a0criptC.I' src,'../include/js/.ietuni-.js' t*pe,6text/ja.ascript67$/script7
$script language,'Wa.a0criptC.I' src,'../include/js/.uspella.js' t*pe,6text/ja.ascript67$/script7
$script t*pe,'text/ja.ascript' src,'../include/nicEdit.js'7$/script7
$form action,add_news.php method,/90: enct*pe,'multipart/form)data'7
PHP cn bn ,
$table align,center7
$tr7
$td7(ategories$/td7
$td7
$select name,categories7
$%
3s5l,'select L from cate_news order b* cate_news_title'+
35uer*,m*s5l_5uer*&3s5l)+
while&3row,m*s5l_fetch_arra*&35uer*))
M
echo '$option .alue,3rowNcate_news_idO7 3rowNcate_news_titleO$/option7'+
P
%7
$/select7
$/td7
$/tr7
$tr7
$td7=o Uo$/td7
$td7
$input t*pe,radio name,'switcher' .alue,'9FF' chec4ed onfocus,'set:*pingBode&D)'7English
$input t*pe,radio name,'switcher' .alue,':E2E@' onfocus,'set:*pingBode&C)'7:elex
$input t*pe,radio name,'switcher' .alue,'.n#ni' onfocus,'set:*pingBode&I)'7#E!
$input t*pe,radio name,'switcher' .alue,'.n#ni' onfocus,'set:*pingBode&?)'7#!X"
$/td7
$/tr7
$tr7
$td7:itle$/td7
$td7$input t*pe,text name,title siQe,?D .alue,'$% if&isset&3_/90:NtitleO)) echo
3_/90:NtitleO+ %7'7$/td7
$/tr7
$tr7
$td7Tuthor$/td7
$td7$input t*pe,text name,author siQe,?D .alue,'$% if&isset&3_/90:NauthorO)) echo
3_/90:NauthorO+ %7'7$/td7
$/tr7
$tr7
$td7!nfo$/td7
$td7$textarea cols,KS rows,K name,info7$% if&isset&3_/90:NinfoO)) echo 3_/90:NinfoO+ %
7$/textarea7$/td7
$/tr7
$tr7
$td7Full$/td7
$td7$textarea cols,RD rows,CI name,full on4e*up,'init:*per&this)+' 7$% if&isset&3_/90:NfullO))
echo 3_/90:NfullO+ %7$/textarea7
$8))$script t*pe,'text/ja.ascript'7
b42ib.on1om2oaded&function&) M
new nicEditor&Mfull/anel : trueP).panel!nstance&6full6)+
P)+
$/script7))7
$/td7
$/tr7
$tr7
$td7!mage$/td7
$td7$input t*pe,file name,img siQe,?D7$/td7
$/tr7
$tr7
$td7(hec4$/td7
$td7 $input t*pe,radio name,chec4 .alue,;7;es
$input t*pe,radio name,chec4 .alue,E chec4ed7Eo
PHP cn bn -
$/td7
$/tr7
$tr7
$td7$/td7
$td7$input t*pe,submit name,addnews .alue,'Tdd T Eews'7$/td7
$/tr7
$/table7
$/form7
e!it#ne)*.php
$%
re5uire&'../include/config.php')+
3id,3_UE:N6newsid6O+
if&isset&3_/90:N6editnews6O))
M
if&3_/90:N6title6O ,, E<22)
M
echo '/lease enter *our title'+
P
else
M
3t,3_/90:N6title6O+
P
if&3_/90:N6author6O ,, E<22)
M
echo '/lease enter *our author'+
P
else
M
3a,3_/90:N6author6O+
P
if&3_/90:N6info6O ,, E<22)
M
echo '/lease enter *our !nformation'+
P
else
M
3i,3_/90:N6info6O+
P
if&3_/90:N6full6O ,, E<22)
M
echo '/lease enter *our Full Eews'+
P
else
M
3f,3_/90:N6full6O+
P
if&3_F!2E0N6img6ON6name6O 8, E<22)
M
mo.e_uploaded_file&3_F!2E0N6img6ON6tmp_name6O, '../data/news/'.3_F!2E0N6img6ON6name6O)+
3image, 'data/news/'.3_F!2E0N6img6ON6name6O+
P
3cate,3_/90:N6categories6O+
3chc,3_/90:N6chec46O+
if&3t G 3a G 3i G 3f G 3image G 3cate G 3chc)
M
3s5l,'update news set news_title,6'.3t.'6, news_author,6'.3a.'6,news_info,6'.3i.'6,
news_full,6'.3f.'6,news_img,6'.3image.'6, news_chec4,6'.3chc.'6, cate_news_id,6'.3cate.'6 where news_id,6'.
3id.'6'+
35uer*,m*s5l_5uer*&3s5l)+
header&'location: mana_news.php')+
exit&)+
P
else
M
PHP cn bn .
if&3t G 3a G 3i G 3f G 3cate G 3chc)
M
3s5l,'update news set news_title,6'.3t.'6, news_author,6'.3a.'6,news_info,6'.3i.'6,
news_full,6'.3f.'6,news_chec4,6'.3chc.'6, cate_news_id,6'.3cate.'6 where news_id,6'.3id.'6'+
35uer*,m*s5l_5uer*&3s5l)+
header&'location: mana_news.php')+
exit&)+
P
P
P
3s5l,'select L from news where news_id,6'.3id.'6'+
35uer*,m*s5l_5uer*&3s5l)+
3rowI,m*s5l_fetch_arra*&35uer*)+
3cate,3rowINcate_news_idO+
%7
$form action,edit_news.php%newsid,$%,3id%7 method,/90: enct*pe,'multipart/form)data'7
$table align,center7
$tr7
$td7(ategories$/td7
$td7
$select name,categories7
$%
3s5l,'select L from cate_news order b* cate_news_title'+
35uer*,m*s5l_5uer*&3s5l)+
while&3row,m*s5l_fetch_arra*&35uer*))
M
if&3rowNcate_news_idO ,, 3cate)
M
echo '$option .alue,3rowNcate_news_idO selected7
3rowNcate_news_titleO$/option7'+
P
else
M
echo '$option .alue,3rowNcate_news_idO7 3rowNcate_news_titleO$/option7'+
P
P
%7
$/select7
$/td7
$/tr7
$tr7
$td7:itle$/td7
$td7$input t*pe,text name,title siQe,?D .alue,'$%,3rowINnews_titleO%7'7$/td7
$/tr7
$tr7
$td7Tuthor$/td7
$td7$input t*pe,text name,author siQe,?D .alue,'$%,3rowINnews_authorO%7'7$/td7
$/tr7
$tr7
$td7!nfo$/td7
$td7$textarea cols,KS rows,K name,info7$%,3rowINnews_infoO%7$/textarea7$/td7
$/tr7
$tr7
$td7Full$/td7
$td7$textarea cols,KS rows,CI name,full7$%,3rowINnews_fullO%7$/textarea7$/td7
$/tr7
PHP cn bn /
$tr7
$td7!mage$/td7
$td7$input t*pe,file name,img siQe,?D7$br /7
$% if&3rowINnews_imgO 8, E<22)
echo '$a href,../3rowINnews_imgO target,_blan47Ainh anh$/a7'+
%7
$/td7
$/tr7
$tr7
$td7(hec4$/td7
$td7 $input t*pe,radio name,chec4 .alue,; $% if&3rowINnews_chec4O ,, ';') echo 'chec4ed'+%
7 7;es
$input t*pe,radio name,chec4 .alue,E $% if&3rowINnews_chec4O ,, 'E') echo
'chec4ed'+%77Eo
$/td7
$/tr7
$tr7
$td7$/td7
$td7$input t*pe,submit name,editnews .alue,'Edit T Eews'7$/td7
$/tr7
$/table7
$/form7
!el#ne)*.php
$%
re5uire&'../include/config.php')+
3id,3_UE:N6newsid6O+
3s5l,'delete from news where news_id,6'.3id.'6'+
m*s5l_5uer*&3s5l)+
header&'location:mana_news.php')+
exit&)+
%7
$n$#ne)*.php
$%
re5uire&'../include/config.php')+
%7
$html7
$head7
$st*le7
tdM
font)famil*:arial+
font)siQe:CIpx+
border:Cpx dotted green+
text)align:center+
bac4ground:pin4+
P
.titleM
bac4ground:green+
color:white+
font)weight:bold+
P
$/st*le7
$/head7
$bod*7
$table width,RDD align,center7
$tr7
$td class,title7Eo$/td7
PHP cn bn 10
$td class,title7:itle$/td7
$td class,title7(ategories$/td7
$td class,title7(hec4$/td7
$td class,title7Edit$/td7
$td class,title71el$/td7
$/tr7
$%
//////////////////////bat dau phan trang///////////////////////////
3sodongCtrang , ?+
if&isset&3_UE:N6page6O))
M
3num_pages, 3_UE:N6page6O+
P
else
M
3dsC,'select L from news as n, cate_news as c_n where n.cate_news_id , c_n.cate_news_id
order b* n.news_id 1E0('+
3rsC,m*s5l_5uer*&3dsC,3connect)+
3num_records,m*s5l_num_rows&3rsC)+
if&3num_records 7 3sodongCtrang)
M
3num_pages, ceil&3num_records / 3sodongCtrang)+
P
else
M
3num_pages, C+
P
P
if&isset&3_UE:N6s6O))
M
3start ,3_UE:N6s6O+
P
else
M
3start ,D+
P
//////////////////////////////////////Khong phan trang///////////////////////////
3s5l,'select L from news as n, cate_news as c_n where n.cate_news_id , c_n.cate_news_id order b*
n.news_id 1E0( limit 3start, 3sodongCtrang'+
35uer*,m*s5l_5uer*&3s5l)+
if&m*s5l_num_rows&35uer*) ,, '')
M
echo '$tr7$td colspan,R align,center7Empt*$/td7$/tr7'+
P
else
M
3stt,D+
while&3row,m*s5l_fetch_arra*&35uer*))
M
3stt VV+
echo '$tr7'+
echo '$td73stt$/td7'+
echo '$td73rowNnews_titleO$/td7'+
echo '$td73rowNcate_news_titleO$/td7'+
if&3rowNnews_chec4O ,, ;)
M
echo '$td7$font color,red7;es$/font7$/td7 '+
P
else
M
echo '$td7$font color,blue7Eo$/font7$/td7 '+
P
echo '$td7$a href,edit_news.php%newsid,3rowNnews_idO7Edit$/a7$/td7'+
PHP cn bn 11
echo '$td7$a href,del_news.php%newsid,3rowNnews_idO71el$/a7$/td7'+
echo '$tr7'+
P
P
%7
$/table7
$%
echo '$p align,center7$font face,tahoma siQe,I7'+
if&3num_pages 7 C)
M
3tranghh , &3start/3sodongCtrang) V C+
if&3tranghh 8, C)
M
//sua lien 4et lai
echo6$a href,'mana_news.php%s,6.&3start ) 3sodongCtrang).6Gpage,6.3num_pages.6'7/re.ious
/ages$/a7 6+
P
for&3i , C+ 3i $, 3num_pages + 3iVV)
M
if&3i 8, 3tranghh)
M
//sua lien 4et lai
echo6$a href,'mana_news.php%s,6.&&3sodongCtrang L &3i ) C))).6Gpage,6.3num_pages.6'76.
3i.6$/a7,6+
P
else
M
echo '$b73i$/b7 '+
P
P
if&3tranghh 8, 3num_pages)
M
//sua lien 4et
echo6 $a href,'mana_news.php%s,6.&3start V 3sodongCtrang).6Gpage,6.3num_pages.6'7Eext
/ages$/a76+
P
P
%7
$!!#&*e1.php
$%
re5uire&'../include/config.php')+
if&isset&3_/90:N6adduser6O))
M
if&3_/90:N6username6O ,, E<22)
M
echo '/lease enter *our username$br /7'+
P
else
M
3u , 3_/90:N6username6O+
P
if&3_/90:N6password6O 8, 3_/90:N6repassword6O)
M
echo ';our password and repassword is not correct$br /7'+
P
else
M
if&3_/90:N6password6O ,, E<22)
M
echo '/lease enter *our password$br /7'+
P
else
M
3p,3_/90:N6password6O+
P
PHP cn bn 1%
P
3l,3_/90:N6le.el6O+
if&3u G 3p G 3l)
M
3s5l,'select L from user where username,6'.3u.'6'+
35uer*,m*s5l_5uer*&3s5l)+
if&m*s5l_num_rows&35uer*) 8, '')
M
echo 'username na* da ton tai$br /7'+
P
else
M
3s5l,'insert into user&username,password,le.el) .alues&6'.3u.'6,6'.mdS&3p).'6,6'.3l.'6)'+
35uer*,m*s5l_5uer*&3s5l)+
header&'location: mana_user.php')+
exit&)+
P
P
P
%7
$form action,add_user.php method,/90:7
2e.el: $select name,le.el7
$option .alue,C7 Bember$/option7
$option .alue,I7 Tdministrator$/option7
$/select7$br /7
<sername: $input t*pe,text name,username siQe,IS7$br /7
/assword: $input t*pe,password name,password siQe,IS7$br /7
"e)password: $input t*pe,password name,repassword siQe,IS7 $br /7
$input t*pe,submit name,adduser .alue,'Tdd Eews <ser'7
$input t*pe,reset .alue,'"eset'7
$/form7
e!it#&*e1.php
$%
re5uire&'../include/config.php')+
3id,3_UE:N6userid6O+
if&isset&3_/90:N6edituser6O))
M
if&3_/90:N6username6O ,, E<22)
M
echo '/lease enter *our username $br /7'+
P
else
M
3u, 3_/90:N6username6O+
P
if&3_/90:N6password6O 8, 3_/90:N6repassword6O)
M
echo ';our /assword and repassword is not correct'+
P
else
M
if&3_/90:N6password6O 8, E<22)
M
3p,3_/90:N6password6O+
P
P
3l,3_/90:N6le.el6O+
if&3u)
M
3s5l,'select L from user where username,6'.3u.'6 and id 8,6'.3id.'6 '+
35uer*,m*s5l_5uer*&3s5l)+
if&m*s5l_num_rows&35uer*) 8, '')
M
echo '<sername na* da ton tai'+
PHP cn bn 1'
P
else
M
if&3u G 3p G 3l)
M
3s5l,'update user set username,6'.3u.'6, password,6'.mdS&3p).'6, le.el,6'.3l.'6 where
id,6'.3id.'6'+
35uer*,m*s5l_5uer*&3s5l)+
header&'location:mana_user.php')+
exit&)+
P
else
M
if&3u G 3l)
M
3s5l,'update user set username,6'.3u.'6, le.el,6'.3l.'6 where id,6'.
3id.'6'+
35uer*,m*s5l_5uer*&3s5l)+
header&'location:mana_user.php')+
exit&)+
P
P
P
P
P
3s5l,'select L from user where id,6'.3id.'6'+
35uer*,m*s5l_5uer*&3s5l)+
3row,m*s5l_fetch_arra*&35uer*)+
%7
$form action,edit_user.php%userid,$%,3id%7 method,/90:7
2e.el: $select name,le.el7
$option .alue,C $% if&3rowNle.elO ,, C) echo 'selected'+ %7 7 Bember$/option7
$option .alue,I $% if&3rowNle.elO ,, I) echo 'selected'+ %77 Tdministrator$/option7
$/select7$br /7
<sername: $input t*pe,text name,username siQe,IS .alue,'$%,3rowNusernameO%7'7$br /7
/assword: $input t*pe,password name,password siQe,IS7$br /7
"e)password: $input t*pe,password name,repassword siQe,IS7 $br /7
$input t*pe,submit name,edituser .alue,'Edit Eews <ser'7
$input t*pe,reset .alue,'"eset'7
$/form7
!el#&*e1.php
$%
re5uire&'../include/config.php')+
3id,3_UE:N6userid6O+
3s5l,'delete from user where id,6'.3id.'6 and id 8, C'+
m*s5l_5uer*&3s5l)+
header&'location:mana_user.php')+
exit&)+
%7
$n$#&*e1.php
$%
re5uire&'../include/config.php')+
%7
$html7
$head7
$st*le7
tdM
font)siQe:CIpx+
font)famil*:arial+
text)align:center+
P
PHP cn bn 1(
.titleM
font)weight:bold+
bac4ground:green+
color:white+
P
$/st*le7
$/head7
$bod*7
$p align,center7$a href,add_user.php7Tdd Eew user$/a7$/p7
$table align,center border,C width,KDD7
$tr7
$td class,title70::$/td7
$td class,title7<sername$/td7
$td class,title7le.el$/td7
$td class,title7Edit$/td7
$td class,title7 1el $/td7
$/tr7
$%
3s5l,'select L from user where id 8, C order b* id 1E0('+
35uer*,m*s5l_5uer*&3s5l)+
if&m*s5l_num_rows&35uer*) ,, '')
M
echo '$tr7$td colspan,S align,center7(hua co du lieu$/td7$/tr7'+
P
else
M
3stt,D+
while&3row,m*s5l_fetch_arra*&35uer*))
M
3sttVV+
echo '$tr7'+
echo '$td73stt$/td7'+
echo '$td73rowNusernameO$/td7'+
if&3rowNle.elO ,, I)
M
echo '$td7$font color,red7Tdmin$/font7$/td7'+
P
else
M
echo '$td7$font color,blue7Bember$/font7$/td7'+
P
echo '$td7$a href,edit_user.php%userid,3rowNidO7Edit$/a7$/td7'+
echo '$td7$a href,del_user.php%userid,3rowNidO71el$/a7$/td7'+
echo '$/tr7'+
P
P
%7
$/table7
*t2le.c**
(Nu CSS dng .tn_CSS th file PHP gi class=tn_CSS)
(Nu CSS dng #tn_CSS th file PHP gi id=tn_CSS) Nn dng cch ny v h t!" #eb $%&
Ycharset 'utf)-'+
/L (00 1ocument L/
L M
margin: Dpx+
P
bod* M
font)famil*:#erdana, Trial, Ael.etica, sans)serif+
font)siQe:CIpx+
margin:auto+
P
HmainM
width:-DDpx+
PHP cn bn 1+
margin: auto+
border)left:Cpx solid HDDFFFF+
border)right:Cpx solid HDDFFFF+
P
HtopM
height:CDDpx+
text)align:center+
color:white+
bac4ground:H((FF?? url&../images/banner.jpg)+
P
HbottomM
clear:both+
bac4ground:HDDFFRR+
height:KDpx+
text)align:center+
color:HFFFFFF+
P
HcontentM
bac4ground: H??FFFF+
P
HleftM
width:CJDpx+
float:left+
P
Hleft hCM
bac4ground:HDDRR((+
color: HFFFFFF+
text)align:center+
font)siQe:CKpx+
P
Hleft ulM
list)st*le)t*pe:none+
margin:Dpx+
padding:Dpx+
P
Hleft ul aM
width:CSDpx+
bac4ground:HRRFFFF+
displa*:bloc4+
color:HFFFFFF+
padding)left:IDpx+
text)decoration:none+
line)height:C-px+
border)bottom:Cpx solid HFFFFFF+
P
Hleft ul a:ho.erM
bac4ground: HFFFF??+
P
Hcontent_mainM
bac4ground:HECECEC+
margin)left:CJDpx+
border)left:Cpx solid HDDRRFF+
P
Hcontent_main hCM
bac4ground: HFFFFDD+
color:white+
PHP cn bn 1,
text)align:left+
padding)left:CDpx+
font)siQe:CKpx+
P
Hcontent_main pM
padding)left:Spx+
padding)right:Spx+
padding)bottom:Spx+
text)align:justif*+
line)height:CSpx+
P
Hcontent_main p imgM
padding:Ipx+
border:Cpx solid HFFFFFF+
margin)right:Spx+
margin)bottom:Spx+
margin)top:Spx+
P
Hcontent_main hIM
text)align:left+
padding)left:CDpx+
ma:CDpx+
font)siQe:CKpx+
P
hrM
clear:left+
border)bottom:Cpx solid green+
P
HotherM
bac4ground: HFFFFDD+
color:white+
text)align:left+
padding)left:CDpx+
font)siQe:CKpx+
font)weight:bold+
P
Hother_newsM
text)align:left+
padding)left:CDpx+
P
Hother_news ulM
text)align:left+
padding)left:CDpx+
P
Hother_news liM
line)height:CSpx+
padding)bottom:?px+
P
nicE!it.3*
1e$!e.t"t
B&oc 1: goi ja.ascript
$script language,'Wa.a0criptC.I' src,'js/.ietuni-.js' t*pe,6text/ja.ascript67$/script7
PHP cn bn 1-
$script language,'Wa.a0criptC.I' src,'js/.uspella.js' t*pe,6text/ja.ascript67$/script7
B&oc %: 9ption chon lua bo go
$input t*pe,radio name,'switcher' .alue,'9FF' chec4ed onfocus,'set:*pingBode&D)'7English
$input t*pe,radio name,'switcher' .alue,':E2E@' onfocus,'set:*pingBode&C)'7:elex
$input t*pe,radio name,'switcher' .alue,'.n#ni' onfocus,'set:*pingBode&I)'7#E!
$input t*pe,radio name,'switcher' .alue,'.n#ni' onfocus,'set:*pingBode&?)'7#!X"
B&oc ': 1ua option .ao text box
on4e*up,'init:*per&this)+'
'i du(
$textarea rows,'CC' name,'message' cols,'KS' st*le,'border: Cpx solid H??RR(('
on4e*up,'init:*per&this)+'7$/textarea7
PHP cn bn 1.