Professional Documents
Culture Documents
Hnh 3.1:
Bc 2.
Trang 1
ng k ti khon
<?php
// khi to cc bin mc nh
$tendangnhap = "";
$tenhienthi = "";
$bat = "checked";
$id = 0;
$loi = "";
$ten = "";
?>
colspan='2'><ul
class=\"cssLoi\">"
$loi
}
// nu d liu hp l
else if ($loi == ""){
$matkhaumahoa = md5($matkhau);
Trang 2
ng k ti khon
$queryInsert
=
"insert
into
taikhoan(tk_ten_dangnhap,
tk_ten_hienthi, tk_matkhau, tk_mo) values('" . trim($tendangnhap) . "','"
. $tenhienthi . "','" . $matkhaumahoa . "', ".$cobat.")";
mysql_query($queryInsert);
// chuyn trang sau khi ng k
if(isset($_GET['taotaikhoan']))
echo "<script>window.location='?functions=taikhoan_quanly';</script>";
else
echo "<script>window.location='?functions=dangnhap';</script>";
}
}
?>
Hnh 3.2:
Khi nhn thm mi chuyn quan thm ti khon ngi dng bn trn.
Khi Click chn ln lin kt bt thc hin cp nht li trng thi ca ti khon
(tng t chc nng cp nht trng thi khuyn mi).
Khi chn sa chuyn qua trang cp nht ti khon
Khi chn lin kt xa:
Can Tho University software center
Trang 3
ng k ti khon
Xc nhn vi ngi dng. Nu ng tin hnh xa, nu khng ng b
qua thao tc xa.
Bc 1.
sau:
<?php
function XoaTaiKhoan($id) {
$queryDelete = "delete from taikhoan where tk_id = " . $id;
mysql_query($queryDelete);
}
function BatTatTaiKhoan($id, $bat) {
$queryupdate = "update taikhoan set tk_mo=".$bat." where tk_id = " .
$id;
mysql_query($queryupdate);
}
function DanhSachTaiKhoan($id, $bat) {
$querySelect = "select * from taikhoan";
mysql_query($querySelect);
}
?>
Bc 2.
<?php
include_once 'Library/taikhoan.php';
if (isset($_GET['do'])) {
if ($_GET['id']) {
if ($_GET['do']== "del") {
XoaTaiKhoan($_GET['id']);
}elseif($_GET['do']== "active"){
BatTatTaiKhoan($_GET['id'],0);
}else{
BatTatTaiKhoan($_GET['id'],1);
}
}
}
Trang 4
ng k ti khon
if (isset($_POST['btnXoa'])) {
for ($i = 0; $i < count($_POST['checkbox']); $i++) {
if ($_POST['checkbox'] > 0) {
if ($i == (count($_POST['checkbox']) - 1)) {
XoaTaiKhoan($_POST['checkbox'][$i]);
} else {
XoaTaiKhoan($_POST['checkbox'][$i]);
}
}
}
}
function taikhoanphantrang()
{
global $pagenum;
global $image_imageedit_path;
global $image_add_path;
global $image_edit_path;
global $image_delete_path;
global $image_on_path;
global $image_off_path;
global $pagenum;
$pageno = 1;
if (isset($_GET["page"])) {
$pageno = $_GET["page"];
}
$querySQL = "select tk_id, tk_ten_hienthi, tk_ten_dangnhap, tk_mo
from taikhoan LIMIT " . (
$pagenum
*
($pageno - 1)) . "," . $pagenum;
$result = mysql_query($querySQL);
while
(list($id,
$tenhienthi,
mysql_fetch_array($result)) {
$tendangnhap,
$mo)
echo "<tr>
<td
class=\"cotCheckBox\"><input
name=\"checkbox[]\"
type=\"checkbox\" id=\"checkbox[]\" value=" . $id . "></td>
<td>" . $tendangnhap . "</td>
<td>" . $tenhienthi . "</td>";
echo "<td class=\"cotNutChucNang\">";
if($mo == 1)
Trang 5
ng k ti khon
echo
href='?functions=taikhoan_quanly&do=active&id=$id'><img
src='$image_on_path'/></a>";
"<a
else
echo
href='?functions=taikhoan_quanly&do=deactive&id=$id'><img
src='$image_off_path'/></a>";
"<a
echo "</td>";
echo
"<td
class=\"cotNutChucNang\"><a
href=\"?functions=taikhoan_capnhat&do=edit&id=" . $id . "\"><img src='" .
$image_edit_path . "'/></a></td>
<td class=\"cotNutChucNang\"><a onclick='return confirmDelete()'
href=\"?functions=taikhoan_quanly&do=del&id=" . $id . "\"><img src='" .
$image_delete_path . "'/></a></td></tr>";
}
$query_count = "select * from taikhoan";
$result_count = mysql_query($query_count);
if (mysql_num_rows($result_count) > 0) {
$paging = phanTrang(mysql_num_rows($result_count), $pageno);
} else {
$paging = "<tr><td class='khongdulieu' colspan='6'>Cha c d
liu</td></tr>";
}
return $paging;
}
?>
border="0"
cellpadding="5"
cellspacing="0"
<tr>
<td class="Header">QUN L TI KHON
</td>
</tr>
<tr>
<td>
<form id="form1" name="form1" method="post" action="">
<table
width="100%"
cellpadding="5" class="TableData">
border="0"
cellspacing="0"
Trang 6
ng k ti khon
<tr>
<td
colspan="6"
class="themmoi"><a
href="?functions=dangky&taotaikhoan=1"><img src="images/add.png"/> Thm
mi</a> </td>
</tr>
<tr>
<th>Chn </th>
<th>Tn ng nhp</th>
<th>Tn hin th</th>
<th>Bt</th>
<th>Sa </th>
<th>Xa</th>
</tr>
<?php $paging = taikhoanphantrang();?>
<strong><tr>
<td
colspan="6"
class="phantrang"><?php
echo
Trang 7