
프론트 엔드(?)
login.php
<!DOCTYPE html>
<html lang="ko" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
table{
align-self: center;
width: auto;
margin: auto;
border-collapse: collapse;
border: thin solid black;
}
input{
width: auto;
}
h1,h2{
text-align: center;
}
</style>
</head>
<body>
<?php
session_start();
if (isset($_SESSION['userid'])) {
?>
<script type="text/javascript">
alert("이미 로그인 되어 있습니다.");
location.replace("index.php");
</script>
<?php
}
?>
<h1>LOGIN</h1>
<form action="login_action.php" method="get">
<table border="1"style="">
<tr>
<td>ID:<input type="text" name="id" placeholder="ID"> </td>
</tr>
<tr>
<td>PW:<input type="password" name="pw" placeholder="PASSWORD"> </td>
</tr>
<tr>
<td><input type="submit"> <input type="button" value="Join" onclick="location.href='join.php'"></td>
</tr>
</table>
</form>
</body>
</html>
백엔드(?)
login_action.php
<?php
session_start();
$id=$_GET['id'];
$pw=$_GET['pw'];
$con = mysqli_connect('localhost','root','----','-----') or die("fail");
$query="select * from acc where id='$id' and pw='$pw'";
$result=mysqli_query($con,$query);
$row=mysqli_fetch_array($result);
if(isset($row)){
$_SESSION['userid']=$row['id'];?>
<script type="text/javascript">
alert("로그인!!");
location.replace("index.php");
</script>
<?php
}
else {
?>
<script type="text/javascript">
alert("아이디 혹은 비밀번호가 틀렸습니다!!");
location.replace("login.php");
</script>
<?php
}
?>
'프로그래밍 > 게시판 만들기' 카테고리의 다른 글
| 로그아웃 (0) | 2019.11.16 |
|---|---|
| 글 작성 write.php write_action.php (0) | 2019.11.16 |
| 글 보기 view.php (0) | 2019.11.16 |
| 회원가입 페이지 join.php, join_action.php (0) | 2019.11.15 |
| 메인화면 index.php(수정 중) (0) | 2019.11.15 |