Compare commits

...

3 Commits

Author SHA1 Message Date
ea5b6d74c4 merge from notif to dev (#6) 2025-11-26 04:41:57 -05:00
Matthew Florentino
e848cb31fc style: final style notif 2025-11-26 11:01:10 +07:00
Matthew Florentino
2dd889153b feat: wait beacuse have bug at index.php 2025-11-26 10:48:57 +07:00
3 changed files with 49 additions and 4 deletions

View File

@ -1,13 +1,15 @@
<?php <?php
session_start(); session_start();
include "config/db.php"; include "config/db.php";
include "notif.php";
if(isset($_POST['login'])){ if(isset($_POST['login'])){
$username = $_POST['username']; $username = $_POST['username'];
$password = $_POST['password']; $password = $_POST['password'];
if(empty($username)||empty($password)){ if(empty($username)||empty($password)){
echo "semua data harus terisi"; $msg = "Data Harus Lengkap !";
echo "<script>showNotif(" . json_encode($msg) . ");</script>";
}else{ }else{
$sql = "SELECT * FROM users WHERE username =?"; $sql = "SELECT * FROM users WHERE username =?";
$stmt = $db -> prepare($sql); $stmt = $db -> prepare($sql);
@ -21,13 +23,15 @@ if(isset($_POST['login'])){
$_SESSION['loggedin']='true'; $_SESSION['loggedin']='true';
$_SESSION['username']=$user['username']; $_SESSION['username']=$user['username'];
$_SESSION['id']=$user['id']; $_SESSION['id']=$user['id'];
header("location:leaderboard.php"); header("location:onboard.php");
exit(); exit();
}else{ }else{
echo "password salah"; $msg = "Password Salah !";
echo "<script>showNotif(" . json_encode($msg) . ");</script>";
} }
}else{ }else{
echo "username salah"; $msg = "Username tidak ditemukan !";
echo "<script>showNotif(" . json_encode($msg) . ");</script>";
} }
$stmt->close(); $stmt->close();
} }
@ -56,6 +60,7 @@ $db->close();
<button type="submit" name="login" placeholder="input your password" data-aos="fade-up" data-aos-duration="3000">LOGIN</button> <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> <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> </form>
<div id="notif" class="notif"></div>
</div> </div>
<script src="https://unpkg.com/aos@2.3.1/dist/aos.js"></script> <script src="https://unpkg.com/aos@2.3.1/dist/aos.js"></script>
<script> <script>

40
src/notif.php Normal file
View File

@ -0,0 +1,40 @@
<div id="notif" class="notif"></div>
<style>
.notif {
position: fixed;
top: 50px;
left: 50%;
transform: translateX(-50%);
background-color: #b2db0e1c;
display: flex;
justify-content: center;
align-items: center;
text-align: center;
color: yellow;
padding: 12px 18px;
width: 300px;
height: 25px;
font-size: 20px;
border: 1px solid yellow;
border-radius: 8px;
opacity: 0;
transition: .3s;
z-index: 9999;
}
.notif.show {
opacity: 1;
}
</style>
<script>
function showNotif(msg) {
const n = document.getElementById("notif");
n.textContent = msg;
n.classList.add("show");
setTimeout(() => {
n.classList.remove("show");
}, 3000);
}
</script>