Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- 해외 wargame
- php
- backdoorctf 2023
- 해킹캠프 ctf
- hackingcamp ctf writeup
- CVE
- Web
- XSS-game
- WarGame
- 해킹캠프
- backdoorctf writeup
- hackctf
- backdoorctf 2023 web
- backdoorctf 2023 web Unintelligible
- hacking
- cve 분석
- Web Hacking
- wargame.kr
- writeup
- RCE
- thinkPHP
- WEB-hacking
- hackingcamp
- 웹해킹
- XSS
- Hacker.org
- webhacking
- 해외 워게임
- CTF
- 웹 해킹
Archives
- Today
- Total
<OOO>
PHP 로그인 처리 본문
728x90
대충 만든거라 그냥 굴러만 가는구나 하는 코드이다.
<?php
include_once "./board/dbconf.php";
session_start();
if(isset($_SESSION['id']))
{
echo ("<script>alert('이미 로그인 중입니다.')</script>");
echo ("<script>history.back();</script>");
exit;
}
$con = mysqli_connect($db_host,$db_user,$db_pw,$db_db);
$id = strip_tags($_POST['id']);
$pw = strip_tags($_POST['pw']);
$id = mysqli_real_escape_string($con, $id);
$pw = mysqli_real_escape_string($con, $pw);
if($id == "" || $pw == "")
{
echo ("<script>alert('빈 칸이 있습니다. 모두 채워주세요.'</script>");
echo ("<script>history.back();</script>");
}
$sql = "select id, password from users where id = '".$id."'";
$query = mysqli_query($con, $sql);
$result = mysqli_num_rows($query);
if($result == 1)
{
$row = mysqli_fetch_array($query);
if($row['password'] == NULL)
{
echo ("<script>alert('아이디 혹은 비밀번호가 틀렸습니다.'</script>");
echo ("<script>history.back();</script>");
}
$dbpw = $row['password'];
if(password_verify($pw, $dbpw))
{
$_SESSION['id'] = $row['id'];
$id = $_SESSION['id'];
echo "$id"."님 환영합니다.";
header("Location:./index");
exit;
}
else
{
echo ("<script>alert('아이디 혹은 비밀번호가 틀렸습니다.')</script>");
echo ("<script>history.back();</script>");
exit;
}
}
else
{
echo ("<script>alert('로그인 실패')</script>");
echo ("<script>history.back();</script>");
exit;
}
mysqli_close($con);
?>
'개발관련' 카테고리의 다른 글
WSL2 docker 시작 실패 오류 해결 (2) | 2022.07.06 |
---|---|
우분투 apache 웹 ip접속 차단 (1) | 2020.08.30 |
PHP id 혹은 닉네임 체크 (0) | 2020.08.30 |
PHP 회원가입 구현 (0) | 2020.08.30 |
Comments