1. 관리자모드와 회원관리
페이지 정보
작성자 관리자 댓글 1건 조회 1,917회 작성일 21-05-22 18:19본문
1. 관리자모드와 회원관리
1. 관리자 등급 수정하기
phpMyAdmin에서 members 테이블의 아이디를 수정하여 등급을 10등급으로 수정한다.
2. 상단 메뉴에 관리자모드 추가하기 : header.php
<?php
session_start();
if (isset($_SESSION["userid"])) $userid = $_SESSION["userid"];
else $userid = "";
if (isset($_SESSION["username"])) $username = $_SESSION["username"];
else $username = "";
if (isset($_SESSION["userlevel"])) $userlevel = $_SESSION["userlevel"];
else $userlevel = "";
?>
<div id="top">
<h3>
<a href="index.php">OOO님의 홈페이지</a>
</h3>
<ul id="top_menu">
<?php
if (!$userid) {
?>
<li><a href="member_form.php">회원 가입</a> </li>
<li> | </li>
<li><a href="login_form.php">로그인</a></li>
<?php
} else {
$logged = $username."(".$userid.")님[Level:".$userlevel."]";
?>
<li><?=$logged?> </li>
<li> | </li>
<li><a href="logout.php">로그아웃</a> </li>
<li> | </li>
<li><a href="member_modify_form.php">정보 수정</a></li>
<?php
}
?>
<?php
if($userlevel==10) {
?>
<li> | </li>
<li><a href="admin.php">관리자 모드</a></li>
<?php
}
?>
</ul>
</div>
<div id="menu_bar">
<ul>
<li><a href="index.php">HOME</a></li>
<li><a href="message_form.php">쪽지함</a></li>
<li><a href="board_form.php">게시판</a></li>
</ul>
</div>
3. 관리자 페이지 : admin.php
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>관리자페이지</title>
<link rel="stylesheet" type="text/css" href="./css/common.css">
<link rel="stylesheet" type="text/css" href="./css/admin.css">
</head>
<body>
<header>
<?php include "header.php";?>
</header>
<section>
<div id="admin_box">
<h3 id="member_title">
관리자 모드 > 회원 관리
</h3>
<ul id="member_list">
<li>
<span class="col1">번호</span>
<span class="col2">아이디</span>
<span class="col3">이름</span>
<span class="col4">레벨</span>
<span class="col5">포인트</span>
<span class="col6">가입일</span>
<span class="col7">수정</span>
<span class="col8">삭제</span>
</li>
<?php
$con = mysqli_connect("localhost", "user1", "12345", "sample");
$sql = "select * from members order by num desc";
$result = mysqli_query($con, $sql);
$total_record = mysqli_num_rows($result); // 전체 회원 수
$number = $total_record;
while ($row = mysqli_fetch_array($result))
{
$num = $row["num"];
$id = $row["id"];
$name = $row["name"];
$level = $row["level"];
$point = $row["point"];
$regist_day = $row["regist_day"];
?>
<li>
<form method="post" action="admin_member_update.php?num=<?=$num?>">
<span class="col1"><?=$number?></span>
<span class="col2"><?=$id?></a></span>
<span class="col3"><?=$name?></span>
<span class="col4"><input type="text" name="level" value="<?=$level?>"></span>
<span class="col5"><input type="text" name="point" value="<?=$point?>"></span>
<span class="col6"><?=$regist_day?></span>
<span class="col7"><button type="submit">수정</button></span>
<span class="col8"><button type="button" onclick="location.href='admin_member_delete.php?num=<?=$num?>'">삭제</button></span>
</form>
</li>
<?php
$number--;
}
?>
</ul>
</div> <!-- admin_box -->
</section>
<footer>
<?php include "footer.php";?>
</footer>
</body>
</html>
첨부파일
- admin.css (1.6K) 35회 다운로드 | DATE : 2021-05-28 14:18:29
댓글목록
관리자님의 댓글
관리자 작성일update `members` set level=10 WHERE id='jklee'