EVOLUTION-NINJA
Edit File: login_page.php
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>VST</title> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous"> <link rel="stylesheet" href="public/assets/css/font-awesome.min.css"> <link rel="stylesheet" href="public/assets/css/loginpage.css"> <!-- poppins fonts --> <link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <script type="text/javascript" src="<?php echo base_url('public/assets/js/jquery-3.6.0.min.js'); ?>"></script> <link href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap" rel="stylesheet"> <script src="<?php echo base_url('public/assets/toastr/toastr.min.js');?>"></script> <link rel="stylesheet" href="<?php echo base_url('public/assets/toastr/toastr.min.css');?>"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/popper.js@1.12.9/dist/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script> </head> <style> .loginimages{ height:100vh; overflow: hidden; } .loginpage{ overflow-x: hidden; } .captha-generater{ background: linear-gradient(135deg,#1e3a8a,#2563eb); padding: 12px 20px; margin: 10px auto; border-radius: 14px; color: #ffeb3b; font-size: 30px; font-weight: bold; font-family: 'Courier New', monospace; letter-spacing: 6px; text-align: center; width: 190px; user-select: none; position: relative; overflow: hidden; transform: skew(-4deg); box-shadow: 0px 6px 15px rgba(0,0,0,0.25); border: 2px solid white; } /* Input label */ .captcha-label{ font-size:16px; font-weight:600; color:#222; margin-bottom:6px; display:block; } /* Red star */ .required-star{ color:red; font-size:18px; } </style> <body> <section class="loginpage"> <div class="logindettails row"> <div class="col-sm-7 login"> <div class="loginform"> <img src="public/assets/images/VST.jpg" alt="Nirmithi Kendra Logo" class="nirmithilogo"> <form id="form"> <div class="inpfields"> <input type="text" placeholder="username" name="username" id="username" minlength="2" maxlength="50" pattern="^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$|^[a-zA-Z0-9_-]{2,50}$" required> <img src="public/assets/images/Frame-1.png" alt="usericon" class="inplogos"> </div> <div class="inpfields"> <input type="password" placeholder="Password" name="password" id="password" class="passwordinput" required> <img src="public/assets/images/Frame.png" alt="password icon" class="inplogos"> <i class="fa fa-eye-slash" aria-hidden="true" id="togglepass"></i> </div> <div class="inpfields"> <!-- <input type="checkbox"> Remember me <a href="#" id="forget-pass">Forgot password?</a> --> <label class="captcha-label"> Enter Captcha <span class="required-star">*</span> </label> <input type="text" placeholder="Enter Captcha" id="usercaptcha"> </br> <i class="fa fa-refresh reficon" aria-hidden="true" onclick='generate()'></i> <div class="captha-generater" id='image'> </div> </div> <button type="submit" class="loginbutton" id="log-btn">Log In</button> </form> </div> </div> </div> </section> </body> <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11.10.8/dist/sweetalert2.all.min.js"></script> <link href="https://cdn.jsdelivr.net/npm/sweetalert2@11.10.8/dist/sweetalert2.min.css" rel="stylesheet"> <script> document.addEventListener('DOMContentLoaded', function () { const eyechange = document.getElementById("togglepass"); const togglepassword = document.querySelector(".passwordinput"); eyechange.addEventListener("click", function () { if (togglepassword.type === "password") { togglepassword.type = "text"; eyechange.classList.remove("fa-eye-slash"); eyechange.classList.add("fa-eye") } else { togglepassword.type = "password"; eyechange.classList.remove("fa-eye"); eyechange.classList.add("fa-eye-slash") } }) }) </script> <script> $('.carousel').carousel({ interval:4000 }) </script> <script> $(document).ready(function () { $('#form').submit(function (e) { e.preventDefault(); const formdata = new FormData($(this)[0]); const captcha = document.getElementById("image").textContent.trim(); // Use textContent instead of innerHTML const usercaptcha = document.getElementById('usercaptcha').value.trim(); if (captcha === usercaptcha) { $('#log-btn').text('Loading...').attr('disabled', 'disabled'); // Improved loading state $('#log-btn').removeAttr('disabled').text('Login'); $.ajax({ type: 'POST', url: '<?php echo base_url("login");?>', data: formdata, contentType: false, processData: false, success: function (response) { if (response.result == 1) { Swal.fire({ icon: "success", title: response.message, showConfirmButton: false, timer: 1000, }).then(function () { window.location.href = response.redirect; }); } else { Swal.fire({ icon: "error", title: response.message || "An error occurred.", }); } }, error: function (xhr, textStatus, errorThrown) { console.error("AJAX Error:", textStatus, errorThrown); $('#log-btn').removeAttr('disabled').text('Login'); // Reset button state Swal.fire({ icon: "error", title: "Something went wrong. Please try again later." }); } }); } else if (usercaptcha === '') { toastr.error('Please enter captcha'); } else { toastr.error('Invalid captcha'); } }); }); </script> <script> let captcha; function generate() { document.getElementById("usercaptcha").value = ""; captcha = document.getElementById("image"); let uniquechar = ""; const randomchar = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; for (let i = 0; i < 6; i++) { uniquechar += randomchar.charAt( Math.floor(Math.random() * randomchar.length) ); } // Random rotation effect let finalCaptcha = ""; for(let char of uniquechar){ let rotate = Math.floor(Math.random() * 30) - 15; finalCaptcha += `<span style=" display:inline-block; transform:rotate(${rotate}deg); ">${char}</span>`; } captcha.innerHTML = finalCaptcha; } generate(); // Generate captcha on page load </script> </html>