feat/login #4

Merged
5803025046 merged 3 commits from feat/login into dev 2025-11-17 21:18:17 -05:00
5 changed files with 98 additions and 1 deletions
Showing only changes of commit 63b488fcec - Show all commits

View File

@ -6,7 +6,7 @@ services:
build: build:
context: . context: .
dockerfile: web/Dockerfile dockerfile: web/Dockerfile
image: codebeater:latest image: kelompok12:latest
container_name: phpapache container_name: phpapache
ports: ports:
- "${APP_PORT}:80" - "${APP_PORT}:80"

View File

@ -0,0 +1,13 @@
<?php
$hostname = "db";
$username = "user";
$password = "user";
$database = "codebeater";
$db = mysqli_connect($hostname, $username, $password, $database);
if(!$db){
die("Koneksi database gagal. Error: " . mysqli_connect_error());
}

View File

@ -0,0 +1,23 @@
@import url('https://fonts.googleapis.com/css2?family=Jersey+15&family=JetBrains+Mono:ital,wght@0,100..800;1,100..800&display=swap');
*{
font-family: "Jersey 15", sans-serif;
margin: 0;
padding: 0;
}
body {
color: white;
background-color: black;
}
.row {
display: flex;
height: 100dvh;
}
.col {
flex: 1;
width: 50%;
padding: 30px;
box-sizing: border-box;
}

View File

@ -0,0 +1,61 @@
<?php
session_start();
include "config/db.php";
if(isset($_POST['login'])){
$username = $_POST['username'];
$password = $_POST['password'];
if(empty($username)||empty($password)){
echo "semua data harus terisi";
}else{
$sql = "SELECT * FROM users WHERE username =?";
$stmt = $db -> prepare($sql);
$stmt->bind_param('s',$username);
$stmt->execute();
$result = $stmt ->get_result();
if($result->num_rows ===1){
$user = $result ->fetch_assoc();
if(password_verify($password,$user['password'])){
$_SESSION['loggedin']='true';
$_SESSION['username']=$user['username'];
$_SESSION['user_id']=$user['user_id'];
header("location:leaderboard.php");
exit();
}else{
echo "password salah";
}
}else{
echo "username salah";
}
$stmt->close();
}
}
$db->close();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>login</title>
<link rel="stylesheet" href="/src/css/global.css">
<link rel="stylesheet" href="/src/css/style.css">
</head>
<body>
<div class="container-login">
<h1 data-aos="zoom-out" data-aos-duration="1000">codebeater</h1>
<form class="login-form" action ="index.php" method="POST">
<h2 data-aos="fade-up" data-aos-duration="1000">Login to your account</h2>
<input type="text" name="username" id="username" placeholder="input your username" data-aos="fade-up" data-aos-duration="2000"><br>
<input type="password" name="password" id="password" placeholder="input your password" data-aos="fade-up" data-aos-duration="2000"><br>
<button type="submit" name="login" placeholder="input your password" data-aos="fade-up" data-aos-duration="3000">LOGIN</button>
<p placeholder="input your password" data-aos="fade-up" data-aos-duration="3000"><a href="register.php">don't have account yet?<span> register now!</span></a></p>
</form>
</div>
</body>
</html>

View File