Edit File: prijavaadmin.php
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script src="../js/jquery.min.js" type="text/javascript"></script> <style> body, html { height: 100%; margin: 0; } .bg { /* The image used */ background-image: url("images/background.jpg"); /* Full height */ height: 100%; /* Center and scale the image nicely */ background-position: center; background-repeat: no-repeat; background-size: cover; } </style> <style> body {font-family: Arial, Helvetica, sans-serif;color:white;} /* Full-width input fields */ input[type=text], input[type=password] { width: 100%; padding: 12px 20px; margin: 8px 0; display: inline-block; border: 1px solid #ccc; box-sizing: border-box; } /* Set a style for all buttons */ button { background-color: #4CAF50; color: white; padding: 14px 20px; margin: 8px 0; border: none; cursor: pointer; width: 100%; } button:hover { opacity: 0.8; } /* Extra styles for the cancel button */ .cancelbtn { width: auto; padding: 10px 18px; background-color: #f44336; } /* Center the image and position the close button */ .imgcontainer { text-align: center; margin: 24px 0 12px 0; position: relative; } img.avatar { width: 3%; border-radius: 50%; } .container { padding: 16px; } span.psw { float: right; padding-top: 16px; color:black; } /* The Modal (background) */ .modal { position: fixed; /* Stay in place */ z-index: 1; /* Sit on top */ left: 0; top: 0; width: 100%; /* Full width */ height: 100%; /* Full height */ overflow: auto; /* Enable scroll if needed */ background-color: rgb(0,0,0); /* Fallback color */ background-color: rgba(0,0,0,0.4); /* Black w/ opacity */ padding-top: 60px; } /* Modal Content/Box */ .modal-content { background-color: #fefefe; margin: 5% auto 15% auto; /* 5% from the top, 15% from the bottom and centered */ border: 1px solid #888; width: 80%; /* Could be more or less, depending on screen size */ } /* The Close Button (x) */ .close { position: absolute; right: 25px; top: 0; color: #000; font-size: 35px; font-weight: bold; } .close:hover, .close:focus { color: red; cursor: pointer; } /* Add Zoom Animation */ .animate { -webkit-animation: animatezoom 0.6s; animation: animatezoom 0.6s } @-webkit-keyframes animatezoom { from {-webkit-transform: scale(0)} to {-webkit-transform: scale(1)} } @keyframes animatezoom { from {transform: scale(0)} to {transform: scale(1)} } /* Change styles for span and cancel button on extra small screens */ @media screen and (max-width: 300px) { span.psw { display: block; float: none; } .cancelbtn { width: 100%; } } </style> </head> <body class="bg"> <div id="id01" class="modal"> <div class="modal-content animate"> <div class="imgcontainer"> <img style="height:128px; width:auto" src="../image/user.jpg" alt="Avatar" class="avatar"> <span onclick="document.getElementById('id01').style.display='none'" class="close" title="Zatvori">×</span> </div> <div class="container" style="color:black;"> <label for="uname"><b>Korisnicko ime</b></label> <input type="text" placeholder="Unesi korisnicko ime" name="uname" id="kori" required> <label for="psw"><b>Lozinka</b></label> <input type="password" placeholder="Unesi lozinku" name="psw" id = "pswi" required> <button onclick="prijava()">Prijava</button> </div> <div class="container" style="background-color:#f1f1f1"> <button type="button" onclick="document.getElementById('id01').style.display='none'" class="cancelbtn">Odustani</button> </div> </div> </div> <script> // Get the modal var modal = document.getElementById('id01'); // When the user clicks anywhere outside of the modal, close it window.onclick = function(event) { if (event.target == modal) { } } </script> <script> function prijava() { var idfirme = 1; var idpj = 0; var korime = document.getElementById("kori").value; var korloz = document.getElementById("pswi").value; if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp211=new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp211=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp211.onreadystatechange=function() { if (xmlhttp211.readyState==4 && xmlhttp211.status==200) { var podaci = jQuery.parseJSON ( xmlhttp211.responseText); var ime = podaci.ime; idfirme = podaci.idf; idpj = podaci.idp; if (idfirme == 0){ alert("Korisnicko ime ili lozinka nisu ispravni, pokusajte ponovo"); window.location.assign("prijavaadmin.php"); }else{ setCookie('username', korime, 7) window.location.assign("index.php?korime="+korime+"&id="+idfirme); } } } //window.location.assign("../pj/prijaviadmin.php?ki="+korime+"&loz="+korloz); xmlhttp211.open("GET","../pj/prijaviadmin.php?ki="+korime+"&loz="+korloz); xmlhttp211.send(); } </script> <script> function setCookie(cname, cvalue, exdays) { var d = new Date(); d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); var expires = "expires="+d.toUTCString(); document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; } function getCookie(cname) { var name = cname + "="; var ca = document.cookie.split(';'); for(var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') { c = c.substring(1); } if (c.indexOf(name) == 0) { return c.substring(name.length, c.length); } } return ""; } function checkCookie() { var user = getCookie("username"); if (user != "") { alert("Welcome again " + user); } else { user = prompt("Please enter your name:", ""); if (user != "" && user != null) { setCookie("username", user, 365); } } } </script> </body> </html>
Back