안녕하세요 관리자 페이지 왼쪽 메뉴 추가
본문
랜덤 아이디 생성 코드인데
이 이거를 관리자 페이지 왼쪽 메뉴
admin.menu200.php <- 여기에 넣고 싶은데
어떻게 하나요
예제로 어떤 사람이 넣은걸 이미지있어서 첨부할게요 ㅠㅠ
<?php
include './_common.php';
include G5_LIB_PATH.'/register.lib.php';
ini_set('display_errors', '1');
$nicknames = [
'천사', '꽃미남', '대박', '사랑', '행복', '반짝', '멋쟁이', '빛나', '상큼', '달콤',
'불금', '희망', '초록', '눈부심', '데일리', '짱구', '미소', '서머', '윈터', '스프링',
'리더', '독수리', '티거', '프렌즈', '나무', '구름', '별빛', '사과', '배', '감성',
'월요병', '불타', '폭발', '아름', '오렌지', '라임', '딸기', '시원', '레인', '파도',
'캔디', '스모크', '질주', '허니', '슈가', '파이', '웜', '닌자', '도적', '마스터',
'킹', '퀸', '왕자', '공주', '용사', '마법사', '전사', '나비', '마녀', '요정',
'픽셀', '트롤', '드래곤', '그리프', '스톰', '불꽃', '빙하', '리프', '땅', '하늘',
'로봇', '강철', '블레이드', '레이저', '우주', '로켓', '별', '행성', '달빛', '태양',
'커피', '카페', '크림', '도넛', '버블', '차', '스무디', '팝콘', '초코', '바닐라',
'자몽', '패션', '매직', '드림', '퓨전', '모카', '로즈', '라벤더', '자스민', '민트'
];
$ids = [
'john', 'james', 'michael', 'david', 'william', 'thomas', 'richard', 'robert', 'charles', 'joseph',
'chris', 'daniel', 'matthew', 'mark', 'paul', 'steven', 'andrew', 'kevin', 'joshua', 'george',
'ryan', 'timothy', 'brian', 'nick', 'ben', 'alex', 'adam', 'aaron', 'scott', 'eric',
'jason', 'tyler', 'brandon', 'anthony', 'jeremy', 'kyle', 'jeffrey', 'gary', 'stephen', 'samuel',
'lucas', 'luke', 'zachary', 'craig', 'greg', 'ian', 'philip', 'brad', 'shawn', 'kenneth',
'edward', 'patrick', 'peter', 'henry', 'douglas', 'jacob', 'jesse', 'lawrence', 'sean', 'frank',
'jerry', 'terry', 'joel', 'jonathan', 'leonard', 'martin', 'mike', 'randy', 'ronald', 'bobby',
'billy', 'carl', 'ralph', 'jimmy', 'jack', 'tony', 'logan', 'dylan', 'max', 'bradley',
'cody', 'derek', 'vince', 'danny', 'leo', 'jordan', 'corey', 'alan', 'jared', 'bruce',
'andy', 'darren', 'gavin', 'jay', 'jamie', 'seth', 'blake', 'cameron', 'todd', 'nathan'
];
$output = '';
$insertedData = [];
if (isset($_POST["mb_id"])) {
foreach ($_POST["mb_id"] as $index => $mb_id) {
$mb_password = $_POST["mb_password"][$index];
$mb_nick = $_POST["mb_nick"][$index];
$mb_level = $_POST["mb_level"][$index];
$sql = "INSERT INTO g5_member (mb_id, mb_password, mb_nick, mb_level) VALUES ('{$mb_id}', '1234', '{$mb_nick}', {$mb_level})";
$result = sql_query($sql);
$insertedData[] = [
'mb_id' => $mb_id,
'mb_password' => '1234',
'mb_nick' => $mb_nick,
'mb_level' => $mb_level,
'status' => $result ? 'Success' : 'Failed'
];
}
$output = 'table';
}
?>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.1/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
<title>회원 데이터 생성</title>
<style>
/* CSS 코드 */
</style>
</head>
<body>
<div class="container">
<h1>회원 데이터 생성기</h1>
<p>이 도구는 랜덤한 회원 데이터를 생성하여 데이터베이스에 삽입하는 데 사용됩니다.</p>
<?php if (!isset($_POST["mb_id"])): ?>
<div>
<label for="countInput">생성할 회원 수:</label>
<input type="number" id="countInput" name="count" min="1" value="1">
<button id="generateButton">생성</button>
</div>
<form action="gen_member.php" method="post" id="membersForm">
<div id="generatedMembers"></div>
<input type="submit" id="submitButton" value="DB 입력" style="display:none;">
</form>
<?php else: ?>
<h2>입력 결과</h2>
<table class="table">
<thead>
<tr>
<th>아이디</th>
<th>비밀번호</th>
<th>닉네임</th>
<th>레벨</th>
<th>입력 결과</th>
</tr>
</thead>
<tbody>
<?php foreach ($insertedData as $data): ?>
<tr>
<td><?php echo $data['mb_id']; ?></td>
<td><?php echo $data['mb_password']; ?></td>
<td><?php echo $data['mb_nick']; ?></td>
<td><?php echo $data['mb_level']; ?></td>
<td><?php echo $data['status']; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<button onclick="location.href='gen_member.php'">처음으로</button>
<?php endif; ?>
</div>
<script>
$(document).ready(function () {
const ids = <?php echo json_encode($ids); ?>;
const nicknames = <?php echo json_encode($nicknames); ?>;
const levels = [3];
$("#generateButton").click(function () {
const count = $("#countInput").val();
let membersHtml = '<table class="table"><thead><tr><th>아이디</th><th>비밀번호</th><th>닉네임</th><th>레벨</th></tr></thead><tbody>';
for (let i = 0; i < count; i++) {
const randomId = ids[Math.floor(Math.random() * ids.length)] + (Math.floor(Math.random() * 900) + 100);
const randomNickname = nicknames[Math.floor(Math.random() * nicknames.length)] + (Math.floor(Math.random() * 900) + 100);
const randomLevel = levels[Math.floor(Math.random() * levels.length)];
membersHtml += '<tr>';
membersHtml += '<td><input type="text" name="mb_id[]" value="' + randomId + '" readonly></td>';
membersHtml += '<td><input type="text" name="mb_password[]" value="1234" readonly></td>';
membersHtml += '<td><input type="text" name="mb_nick[]" value="' + randomNickname + '" readonly></td>';
membersHtml += '<td><input type="text" name="mb_level[]" value="' + randomLevel + '" readonly></td>';
membersHtml += '</tr>';
}
membersHtml += '</tbody></table>';
$("#generatedMembers").html(membersHtml);
$("#submitButton").show();
});
});
</script>
</body>
</html>
답변 2
메뉴에 추가 후 adm에 파일이 있다면
<?php
$sub_menu = '200150'; //메뉴추가한번호
include './_common.php';
include G5_LIB_PATH.'/register.lib.php';
ini_set('display_errors', '1');
$g5['title'] = '랜덤 아이디 생성';
include_once './admin.head.php';
$nicknames = [
'천사', '꽃미남', '대박', '사랑', '행복', '반짝', '멋쟁이', '빛나', '상큼', '달콤',
'불금', '희망', '초록', '눈부심', '데일리', '짱구', '미소', '서머', '윈터', '스프링',
'리더', '독수리', '티거', '프렌즈', '나무', '구름', '별빛', '사과', '배', '감성',
'월요병', '불타', '폭발', '아름', '오렌지', '라임', '딸기', '시원', '레인', '파도',
'캔디', '스모크', '질주', '허니', '슈가', '파이', '웜', '닌자', '도적', '마스터',
'킹', '퀸', '왕자', '공주', '용사', '마법사', '전사', '나비', '마녀', '요정',
'픽셀', '트롤', '드래곤', '그리프', '스톰', '불꽃', '빙하', '리프', '땅', '하늘',
'로봇', '강철', '블레이드', '레이저', '우주', '로켓', '별', '행성', '달빛', '태양',
'커피', '카페', '크림', '도넛', '버블', '차', '스무디', '팝콘', '초코', '바닐라',
'자몽', '패션', '매직', '드림', '퓨전', '모카', '로즈', '라벤더', '자스민', '민트'
];
$ids = [
'john', 'james', 'michael', 'david', 'william', 'thomas', 'richard', 'robert', 'charles', 'joseph',
'chris', 'daniel', 'matthew', 'mark', 'paul', 'steven', 'andrew', 'kevin', 'joshua', 'george',
'ryan', 'timothy', 'brian', 'nick', 'ben', 'alex', 'adam', 'aaron', 'scott', 'eric',
'jason', 'tyler', 'brandon', 'anthony', 'jeremy', 'kyle', 'jeffrey', 'gary', 'stephen', 'samuel',
'lucas', 'luke', 'zachary', 'craig', 'greg', 'ian', 'philip', 'brad', 'shawn', 'kenneth',
'edward', 'patrick', 'peter', 'henry', 'douglas', 'jacob', 'jesse', 'lawrence', 'sean', 'frank',
'jerry', 'terry', 'joel', 'jonathan', 'leonard', 'martin', 'mike', 'randy', 'ronald', 'bobby',
'billy', 'carl', 'ralph', 'jimmy', 'jack', 'tony', 'logan', 'dylan', 'max', 'bradley',
'cody', 'derek', 'vince', 'danny', 'leo', 'jordan', 'corey', 'alan', 'jared', 'bruce',
'andy', 'darren', 'gavin', 'jay', 'jamie', 'seth', 'blake', 'cameron', 'todd', 'nathan'
];
$output = '';
$insertedData = [];
$pw = '1234';
if (isset($_POST["mb_id"])) {
foreach ($_POST["mb_id"] as $index => $mb_id) {
$mb_password = $_POST["mb_password"][$index];
$mb_nick = $_POST["mb_nick"][$index];
$mb_level = $_POST["mb_level"][$index];
$sql = "INSERT INTO g5_member (mb_id, mb_password, mb_nick, mb_level) VALUES ('{$mb_id}', '{$pw}', '{$mb_nick}', {$mb_level})";
$result = sql_query($sql);
$insertedData[] = [
'mb_id' => $mb_id,
'mb_password' => $pw,
'mb_nick' => $mb_nick,
'mb_level' => $mb_level,
'status' => $result ? 'Success' : 'Failed'
];
}
$output = 'table';
}
?>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.1/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
<style>
.container {-ms-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-align:center;-ms-flex-pack:justify;justify-content:space-between}
.table{width:100%;margin-bottom:1rem;color:#212529}
.table td,.table th{padding:5px 0;vertical-align:top;border-top:1px solid #dee2e6}
.table thead th{vertical-align:bottom;padding:5px 0;border-bottom:2px solid #dee2e6;text-align:left}
p {padding:10px 0}
</style>
<div class="container">
<h1>회원 데이터 생성기</h1>
<p>이 도구는 랜덤한 회원 데이터를 생성하여 데이터베이스에 삽입하는 데 사용됩니다.</p>
<?php if (!isset($_POST["mb_id"])): ?>
<div>
<label for="countInput">생성할 회원 수:</label>
<input type="number" id="countInput" name="count" min="1" value="1">
<button id="generateButton">생성</button>
</div>
<form action="gen_member.php" method="post" id="membersForm">
<div id="generatedMembers"></div>
<input type="submit" id="submitButton" value="DB 입력" style="display:none;">
</form>
<?php else: ?>
<h2>입력 결과</h2>
<table class="table">
<thead>
<tr>
<th>아이디</th>
<th>비밀번호</th>
<th>닉네임</th>
<th>레벨</th>
<th>입력 결과</th>
</tr>
</thead>
<tbody>
<?php foreach ($insertedData as $data): ?>
<tr>
<td><?php echo $data['mb_id']; ?></td>
<td><?php echo $data['mb_password']; ?></td>
<td><?php echo $data['mb_nick']; ?></td>
<td><?php echo $data['mb_level']; ?></td>
<td><?php echo $data['status']; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<button onclick="location.href='gen_member.php'">처음으로</button>
<?php endif; ?>
</div>
<script>
$(document).ready(function () {
const ids = <?php echo json_encode($ids); ?>;
const nicknames = <?php echo json_encode($nicknames); ?>;
const levels = [2];
$("#generateButton").click(function () {
const count = $("#countInput").val();
let membersHtml = '<table class="table"><thead><tr><th>아이디</th><th>비밀번호</th><th>닉네임</th><th>레벨</th></tr></thead><tbody>';
for (let i = 0; i < count; i++) {
const randomId = ids[Math.floor(Math.random() * ids.length)] + (Math.floor(Math.random() * 900) + 100);
const randomNickname = nicknames[Math.floor(Math.random() * nicknames.length)] + (Math.floor(Math.random() * 900) + 100);
const randomLevel = levels[Math.floor(Math.random() * levels.length)];
membersHtml += '<tr>';
membersHtml += '<td><input type="text" name="mb_id[]" value="' + randomId + '" readonly></td>';
membersHtml += '<td><input type="text" name="mb_password[]" value="<?php echo $pw; ?>" readonly></td>';
membersHtml += '<td><input type="text" name="mb_nick[]" value="' + randomNickname + '" readonly></td>';
membersHtml += '<td><input type="text" name="mb_level[]" value="' + randomLevel + '" readonly></td>';
membersHtml += '</tr>';
}
membersHtml += '</tbody></table>';
$("#generatedMembers").html(membersHtml);
$("#submitButton").show();
});
});
</script>
<?php
include_once './admin.tail.php';
$menu['menu200'] = array(
array('200000', '회원관리', G5_ADMIN_URL . '/member_list.php', 'member'),
array('200100', '회원관리', G5_ADMIN_URL . '/member_list.php', 'mb_list'),
array('200150', '랜덤아이디생성', G5_ADMIN_URL . '/member_random.php', 'mb_list'),
array('200300', '회원메일발송', G5_ADMIN_URL . '/mail_list.php', 'mb_mail'),
array('200800', '접속자집계', G5_ADMIN_URL . '/visit_list.php', 'mb_visit', 1),
array('200810', '접속자검색', G5_ADMIN_URL . '/visit_search.php', 'mb_search', 1),
array('200820', '접속자로그삭제', G5_ADMIN_URL . '/visit_delete.php', 'mb_delete', 1),
array('200200', '포인트관리', G5_ADMIN_URL . '/point_list.php', 'mb_point'),
array('200900', '투표관리', G5_ADMIN_URL . '/poll_list.php', 'mb_poll')
);
이라고 admin.menu200.php 수정하신후에
member_random.php 에 위에 소스로 파일을 만드시면 될듯 합니다.
!-->
답변을 작성하시기 전에 로그인 해주세요.