Thiết kế website bán hàng | Trang Admin: Quản lý thàn viên đăng ký và mua hàng

Ở phần này sẽ hướng dẫn các bạn liệt kê danh sách và chỉnh sửa thông tin của thành viên chứ không cần tạo mới

Tạo file với tên member.php

<?php include ‘inc_checklogin.php’;
include ‘../includes/functions.php’;
if($_GET[‘delete’]){
mysql_query(“DELETE FROM lesson_user WHERE id = “.intval($_GET[‘delete’]));
header(‘location: member.php’);
exit();

}
?>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>Shop Admin</title>
<link rel=”stylesheet” type=”text/css” href=”style.css”>
</head>

<body>
<?php include ‘inc_header.php’;?>
<table width=”100%” border=”0″ cellspacing=”0″ cellpadding=”0″>
<tr>
<td width=”18%” valign=”top”><?php include ‘inc_menu.php’;?></td>
<td width=”82%” valign=”top”><h2>Thành viên</h2>
<table width=”100%” border=”0″ cellspacing=”0″ cellpadding=”0″>
<tr bgcolor=”#CCCCCC”>
<th width=”87%”>Tên</th>
<th width=”13%”>Công cụ</th>
</tr>
<?php
$sql = “SELECT * FROM lesson_user”;
$total_sql = mysql_query($sql);
$total = mysql_num_rows($total_sql);

$limit = 10;
$page = intval($_GET[‘p’]);
$start = $page * $limit;
$sql .= ” LIMIT $start,$limit”;

$sql = mysql_query($sql);
while($rs = mysql_fetch_assoc($sql)){ ?>
<tr>
<td><?php echo $rs[‘username’];?></td>
<td align=”center”><a href=”member_edit.php?id=<?php echo $rs[‘id’];?>”>Edit</a> <a href=”member.php?delete=<?php echo $rs[‘id’];?>”>Xóa</a></td>
</tr>
<?php } ?>
<tr bgcolor=”#eeeeee”>
<td><?php
$url = ‘member.php’;
echo page($url,$total,$page,$limit);
?></td>
<td align=”center”>&nbsp;</td>
</tr>

</table></td>
</tr>
</table>
<?php include ‘inc_footer.php’;?>
</body>

</html>

Tạo file với tên member_edit.php

<?php include ‘inc_checklogin.php’;
if($_POST){
$email = addslashes($_POST[’email’]);
$fullname = addslashes($_POST[‘fullname’]);
$address = addslashes($_POST[‘address’]);
$tel = addslashes($_POST[‘tel’]);

mysql_query(“UPDATE lesson_user SET email = ‘$email’,fullname =’$fullname’,address = ‘$address’,tel = ‘$tel’ WHERE id = “.intval($_GET[‘id’]));
header(‘location: member.php’);
exit();
}
?>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>Shop Admin</title>
<link rel=”stylesheet” type=”text/css” href=”style.css”>
</head>

<body>
<?php include ‘inc_header.php’;?>
<table width=”100%” border=”0″ cellspacing=”0″ cellpadding=”0″>
<tr>
<td width=”18%”><?php include ‘inc_menu.php’;?></td>
<td width=”82%”><h2>Cập nhật thành viên</h2>

<form id=”form1″ name=”form1″ method=”post” action=””>
<?php
$result = array();
if(is_numeric($_GET[‘id’])){
$sql = “SELECT * FROM lesson_user WHERE id = “.$_GET[‘id’];

$sql = mysql_query($sql);
$result = mysql_fetch_assoc($sql);
}
?>
<table width=”100%” border=”0″ cellspacing=”0″ cellpadding=”0″>
<tr>
<td width=”19%”>Tài khoản</td>
<td width=”81%”><?php echo $result[‘username’];?></td>
</tr>
<tr>
<td width=”19%”>Email</td>
<td width=”81%”><input type=”text” name=”email” id=”email” value=”<?php echo $result[’email’];?>” /></td>
</tr>
<tr>
<td width=”19%”>Tên đầy đủ</td>
<td width=”81%”><input type=”text” name=”fullname” id=”fullname” value=”<?php echo $result[‘fullname’];?>” /></td>
</tr>
<tr>
<td width=”19%”>Địa chỉ</td>
<td width=”81%”><input type=”text” name=”address” id=”address” value=”<?php echo $result[‘address’];?>” /></td>
</tr>
<tr>
<td width=”19%”>Điện thoại</td>
<td width=”81%”><input type=”text” name=”tel” id=”tel” value=”<?php echo $result[‘tel’];?>” /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type=”submit” name=”button” id=”button” value=”Submit” /></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
<?php include ‘inc_footer.php’;?>
</body>

</html>

Chúc các bạn thành công,
Thiết kế số | Thiết kế website
FOLLOW US

Leave a Reply

Your email address will not be published. Required fields are marked *