index.php (1505B)
1 <?php 2 session_start(); 3 4 # Check to see if user is already logged in 5 # TODO: is there a better way to do this? 6 if (isset($_SESSION['is_logged_in'])) { 7 if ($_SESSION['is_logged_in'] == 1) { 8 # Redirect to user's home if so; no need to login again 9 echo "<script type='text/javascript'> 10 window.location.replace('home.php'); 11 </script>"; 12 } 13 } else { 14 # If variable is not set, set it with value 0 15 $_SESSION['is_logged_in'] = 0; 16 } 17 ?> 18 19 <!DOCTYPE html> 20 <html lang='en-CA'> 21 <head> 22 <title>COSC4426AE-21F: Assignment II - Login</title> 23 <?php include 'import/head.html'; ?> 24 </head> 25 26 <body> 27 <header id='login_header'> 28 <h1>COSC4606 Assignment II</h1> 29 </header> 30 31 <main> 32 <!--<form id='login_form' action='login.php' method='POST'>--> 33 <form id='login_form' action=''> 34 <label for='user'>Username:</label><br> 35 <input type='text' id='user' name='user'><br> 36 <label for='pwd'>Password:</label><br> 37 <input type='password' autocomplete='off' id='pwd' name='pwd'> 38 <input type='checkbox' onclick='toggle()'>Show Password<br> 39 <input type='submit' value='Login' id='login'> 40 </form> 41 </main> 42 </body> 43 <?php include 'import/js.html'; ?> 44 <script type='text/javascript' src='/js/login.js'></script> 45 </html>