<?php // Initialize the session session_start(); $guser= $_SESSION["guser"] ; // Check if the user is logged in, if not then redirect him to login page if(!isset($_SESSION["loggedin"]) || $_SESSION["loggedin"] !== true){ // header("location: login.php"); // exit; } else { if (intval($guser)>0) header("location: cosmos.php"); else header("location: kosmo.php"); } ?> <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> body, html { height: 100%; font-family: Arial, Helvetica, sans-serif; } * { box-sizing: border-box; } body { background: url(img/cnc.jpg) no-repeat center center fixed; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover; } .bg-img { /* The image used */ background-image: url("cnc.jpg"); min-height: 380px; /* Center and scale the image nicely */ background-position: center; background-repeat: no-repeat; background-size: cover; position: relative; background-size: 100% ; } /* Add styles to the form container */ .container { position: absolute; right: 0; margin: 20px; max-width: 300px; padding: 16px; background-color: white; border-radius: 8px; } /* Full-width input fields */ input[type=text], input[type=password] { width: 100%; padding: 15px; margin: 5px 0 22px 0; border: none; background: #f1f1f1; } input[type=text]:focus, input[type=password]:focus { background-color: #ddd; outline: none; } /* Set a style for the submit button */ .btn { background-color: #04AA6D; color: white; padding: 16px 20px; border: none; cursor: pointer; width: 100%; opacity: 0.9; } .btn:hover { opacity: 1; } .gl { -webkit-box-shadow: 0 15px 10px #777; -moz-box-shadow: 0 15px 10px #777; box-shadow: 0px 20px 15px -20px #bbb; } </style> </head> <body> <center><img src=img/logo_2.png style="width:188px;"></center> <div class="bg-imsg "> <form id="login-form" onsubmit="return login()" class="container gl"> <h1>Login</h1> <?php $username= $_SESSION["username"]; ?> <label>Username</label> <input type="text" name="username" placeholder="Enter username" id="username" value="<?php echo $username;?>" required> <span class="help-block"></span> <label for="psw"><b>Password</b></label> <input type="password" placeholder="Enter Password" id="userpass" name="password" required> <input type="checkbox" onclick="mypasswordchk()"><span style="cursor:pointer;" onclick="mypasswordchk()">👁 Password</span><br> <span class="help-block"></span> <button type="submit" class="btn">Login</button> <p>Don't have an account? <a href="consent.html">Sign up now</a>.</p> </form> </div> <script> function mypasswordchk() { var x = document.getElementById("userpass"); if (x.type === "password") { x.type = "text"; } else { x.type = "password"; } } function login(){ // (A) GET EMAIL + PASSWORD var data = new FormData(); data.append('username', document.getElementById("username").value); data.append('password', document.getElementById("userpass").value); // (B) AJAX REQUEST var xhr = new XMLHttpRequest(); xhr.open("POST", "donna.php"); xhr.onload = function() { if (this.response == "OK") { location.href = "donka.php"; } else { alert(this.response); } //alert(this.response); }; xhr.send(data); return false; } </script> </body> </html>
Edit file:welcome.php4229