merge from notif to dev #6

Merged
5803025047 merged 2 commits from notif into dev 2025-11-26 04:41:57 -05:00
3 changed files with 46 additions and 2 deletions
Showing only changes of commit 2dd889153b - Show all commits

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 diisi!";
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);
@ -24,7 +26,8 @@ if(isset($_POST['login'])){
header("location:leaderboard.php"); header("location:leaderboard.php");
exit(); exit();
}else{ }else{
echo "password salah"; $msg = "Password Salah!";
echo "<script>showNotif(" . json_encode($msg) . ");</script>";
} }
}else{ }else{
echo "username salah"; echo "username salah";
@ -56,6 +59,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: 100px;
left: 50%;
transform: translateX(-50%);
background-color: #00000060;
display: flex;
justify-content: center;
align-items: center;
text-align: center;
color: yellow;
padding: 12px 18px;
width: 500px;
height: 200px;
font-size: 30px;
border: 1px solid white;
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>