Skip to content

Instantly share code, notes, and snippets.

@ayaysir
Last active February 11, 2020 02:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ayaysir/59c7e34a71cb90b569b9f09f870c8a62 to your computer and use it in GitHub Desktop.
Save ayaysir/59c7e34a71cb90b569b9f09f870c8a62 to your computer and use it in GitHub Desktop.
<?php
header('Content-Type: text/html; charset=utf-8');
$pst_url = $_POST['url'];
echo $pst_url."<br>";
include "./../../init-db.php";
$sql = "update misc set value = '$pst_url' where service_category = 'now' and service_name = 'url'";
$result = $mysqli->query($sql);
echo "result: ".$result."<br>";
if($result >= 1){
echo "<a href='./../index.php'>now 바로가기</a>";
}
?>
<?php session_start(); ?>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<?php
if(!isset($_SESSION['now_username'])) {
?>
<script>
document.location.href = './login.php';
</script>
<?php
} else if($_SESSION['now_username'] == "admin") {
?>
<form action="./enroll_proc.php" method="post">
주소: <input type="url" id="input-url" name="url"><button>전송</button>
</form>
<?php
}
?>
</body>
</html>
<?php
include "./../init-db.php";
$sql = "select * from misc where service_category='now' and service_name='url'";
$result = $mysqli->query($sql);
$row = $result->fetch_array(MYSQLI_ASSOC);
$url = $row['value'];
//echo $url;
header("Location: ".$url);
?>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>now - 로그인</title>
</head>
<body>
<form action="./login_proc.php" method="post">
id: <input type="text" name="username"><br>
pwd: <input type="password" name="password"><br>
<button>전송</button>
</form>
</body>
</html>
<?php
session_start();
include "./../../init-db.php";
$pst_id = $_POST['username'];
$pst_pwd = $_POST['password'];
if($pst_id == "admin"){
$sql = "select * from person_mysql where name = '$pst_id'";
$result = $mysqli->query($sql);
if($result->num_rows == 1){
$row = $result->fetch_array(MYSQLI_ASSOC);
$hash = $row['password'];
if (password_verify($pst_pwd, $hash)) {
$_SESSION['now_username'] = "admin";
echo "<script>document.location.href='./index.php';</script>";
} else {
echo 'Invalid password.';
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment