3. 로그인과 회원정보수정 페이지 제작
페이지 정보
작성자 관리자 댓글 6건 조회 2,338회 작성일 21-05-08 09:18본문
3. 로그인과 회원정보수정 페이지 제작
첨부파일
- login_css.zip (5.6K) 64회 다운로드 | DATE : 2021-05-08 09:21:03
댓글목록
관리자님의 댓글
관리자 작성일
10/login_form.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/login.css">
</head>
<body>
<header>
<?php include "header.php";?>
</header>
<section>
<div id="main_content">
<div id="login_box">
<div id="login_title">
<span>로그인</span>
</div>
<div id="login_form">
<form name="login_form" method="post" action="login.php">
<ul>
<li><input type="text" name="id" placeholder="아이디" ></li>
<li><input type="password" id="pass" name="pass" placeholder="비밀번호" ></li>
<!-- pass -->
</ul>
<div id="login_btn">
<input type="submit" value="확인">
</div>
</form>
</div> <!-- login_form -->
</div> <!-- login_box -->
</div> <!-- main_content -->
</section>
<footer>
<?php include "footer.php";?>
</footer>
</body>
</html>
관리자님의 댓글
관리자 작성일
10/ login.php
<?php
session_start();
$id = $_POST["id"];
$pass = $_POST["pass"];
$con = mysqli_connect("localhost", "user1", "12345", "sample");
$sql = "select * from members where id='$id'";
$result = mysqli_query($con, $sql);
$num_match = mysqli_num_rows($result);
if(!$num_match) {
echo("<script>
window.alert('등록되지 않은 아이디입니다!')
history.go(-1)
</script> ");
} else {
$row = mysqli_fetch_array($result);
$db_pass = $row["pass"];
mysqli_close($con);
if($pass != $db_pass) {
echo("<script>
window.alert('비밀번호가 틀립니다!')
history.go(-1)
</script> ");
exit;
} else {
$_SESSION["userid"] = $row["id"];
$_SESSION["username"] = $row["name"];
$_SESSION["userlevel"] = $row["level"];
echo(" <script> location.href = 'index.php'; </script> ");
}
}
?>
관리자님의 댓글
관리자 작성일
10/logout.php
<?php
session_start();
unset($_SESSION["userid"]);
unset($_SESSION["username"]);
unset($_SESSION["userlevel"]);
echo("<script> location.href = 'index.php';</script> ");
?>
관리자님의 댓글
관리자 작성일
10/member_modify_form.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/member.css">
</head>
<body>
<header>
<?php include "header.php";?>
</header>
<?php
$con = mysqli_connect("localhost", "user1", "12345", "sample");
$sql = "select * from members where id='$userid'";
$result = mysqli_query($con, $sql);
$row = mysqli_fetch_array($result);
$pass = $row["pass"];
$name = $row["name"];
$email = $row["email"];
mysqli_close($con);
?>
<section>
<div id="main_img_bar">
<img src="./img/main_img.png">
</div>
<div id="main_content">
<div id="join_box">
<form name="member_form" method="post" action="member_modify.php?id=<?=$userid?>">
<h2>회원 정보수정</h2>
<div class="form id">
<div class="col1">아이디</div>
<div class="col2">
<?=$userid?>
</div>
</div>
<div class="clear"></div>
<div class="form">
<div class="col1">비밀번호</div>
<div class="col2">
<input type="password" name="pass" value="<?=$pass?>">
</div>
</div>
<div class="clear"></div>
<div class="form">
<div class="col1">비밀번호 확인</div>
<div class="col2">
<input type="password" name="pass_confirm" value="<?=$pass?>">
</div>
</div>
<div class="clear"></div>
<div class="form">
<div class="col1">이름</div>
<div class="col2">
<input type="text" name="name" value="<?=$name?>">
</div>
</div>
<div class="clear"></div>
<div class="form email">
<div class="col1">이메일</div>
<div class="col2">
<input type="text" name="email" value="<?=$email?>">
</div>
</div>
<div class="clear"></div>
<div class="bottom_line"> </div>
<div class="buttons">
<input type="submit" value="확인">
<input type="reset" value="다시입력">
</div>
</form>
</div> <!-- join_box -->
</div> <!-- main_content -->
</section>
<footer>
<?php include "footer.php";?>
</footer>
</body>
</html>
관리자님의 댓글
관리자 작성일
10/member_modify.php
<?php
$id = $_GET["id"];
$pass = $_POST["pass"];
$name = $_POST["name"];
$email = $_POST["email"];
$con = mysqli_connect("localhost", "user1", "12345", "sample");
$sql = "update members set pass='$pass', name='$name' , email='$email'";
$sql .= " where id='$id'";
mysqli_query($con, $sql);
mysqli_close($con);
echo "
<script>
location.href = 'index.php';
</script>
";
?>
관리자님의 댓글
관리자 작성일
10/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
}
?>
</ul>
</div>
<div id="menu_bar">
<ul>
<li><a href="index.php">HOME</a></li>
</ul>
</div>