-
Notifications
You must be signed in to change notification settings - Fork 1
/
member-enter.php
1 lines (1 loc) · 5.75 KB
/
member-enter.php
1
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>ATI Kegalle - Enter as a Member</title> <link href="snackbar.css" rel="stylesheet"/> <!-- Font Awesome --> <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css" rel="stylesheet" /> <!-- Google Fonts --> <link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" rel="stylesheet" /> <!-- MDB --> <link href="https://cdnjs.cloudflare.com/ajax/libs/mdb-ui-kit/3.5.0/mdb.min.css" rel="stylesheet" /> </head> <body> <?php date_default_timezone_set( "Asia/Colombo" ); function navigate( $location = null, $msg = null ) { if ( $msg == null ) { echo '<script>window.location.replace("' . $location . '");</script>'; } else { echo '<script>window.location.replace("' . $location . '?msg=' . $msg . '");</script>'; } } session_start(); if ( isset( $_SESSION[ "member-visit" ] ) && $_SESSION[ "member-visit" ] != "" ) { navigate( "out.php" ); exit; } ?> <div id="snackbar">Incorrect Username/Password Plese recheck and enter again</div> <script type="text/javascript" src="snackbar.js"></script> <!-- Navbar --> <nav class="navbar navbar-expand-lg navbar-dark mb-3" style="background-color:#03045e;"> <!-- Container wrapper --> <div class="container-fluid"> <!-- Navbar brand --> <a class="navbar-brand" href="index.html"><img src="assets/logo.png" width="30" height="30" alt=""></a> <!-- Toggle button --> <button class="navbar-toggler" type="button" data-mdb-toggle="collapse" data-mdb-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"> <i class="fas fa-bars"></i> </button> <!-- Collapsible wrapper --> <div class="collapse navbar-collapse" id="navbarSupportedContent"> <ul class="navbar-nav me-auto mb-2 mb-lg-0 "> <!-- Link --> <li class="nav-item"> <a class="nav-link" href="announcement.html">Announcements</a> </li> <li class="nav-item"> <a class="nav-link" href="gallery.html">Gallery</a> </li> <li class="nav-item"> <a class="nav-link" href="contact.html">Contact Us</a> </li> <li class="nav-item"> <a class="nav-link" href="member-enter.html"> <text style="color: aqua;"><strong>Enter ATI</strong> </text> </a> </li> <!-- Login Dropdown --> <li class="nav-item dropdown"> <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-mdb-toggle="dropdown" aria-expanded="false"> <i class="fa fa-fw fa-user"></i> </a> <!-- Dropdown menu --> <ul class="dropdown-menu" aria-labelledby="navbarDropdown"> <li> <a class="dropdown-item" href="profile.html">Your Profile</a> </li> <li> <a class="dropdown-item" href="register.html">Register</a> </li> <li> <a class="dropdown-item" href="login.html">Login</a> </li> </ul> </li> </ul> </div> </div> <!-- Container wrapper --> </nav> <!-- Navbar --> <!--Content--> <div class="container"> <div class="login-container text-center"> <div> <h1 class="logo-badge"><span class="fas fa-address-book"></span></h1> </div> <h3 class="text-whitesmoke mb-4">Enter as a Member</h3> <form method="post" action="member-enter.php"> <div class="col d-flex justify-content-center"> <!-- Email input --> <div class="form-outline mb-4"> <input type="text" id="form1Example1" required name="username" class="form-control" /> <label class="form-label" for="form1Example1">Username</label> </div> </div> <div class="col d-flex justify-content-center"> <!-- Password input --> <div class="form-outline mb-4"> <input type="password" id="form1Example2" required name="password" class="form-control" /> <label class="form-label" for="form1Example2">Password</label> </div> </div> <!-- 2 column grid layout for inline styling --> <div class="row mb-4"> <div class="col d-flex justify-content-center"> <div class="col"> <!-- Simple link --> <a href="visitor-enter.php" >Not a member of ATI Kegalle?<br /> Click here.</a > </div> </div> </div> <!-- Submit button --> <button type="submit" name="submit" class="btn btn-primary">Submit</button> </form> <?php if ( isset( $_POST[ 'submit' ] ) ) { require 'conn.php'; $username = mysqli_real_escape_string( $conn, $_POST[ 'username' ] ); $password = mysqli_real_escape_string( $conn, $_POST[ 'password' ] ); $sql = "SELECT * FROM `member` WHERE `MemUName`='" . $username . "' AND `Mempassword`='" . $password . "';"; $result = $conn->query( $sql ); if ( $result->num_rows > 0 ) { require 'conn.php'; $sql = "INSERT INTO `member_log`(`MemUName`, `Date`, `TimeIn`) VALUES ('" . $_POST[ 'username' ] . "','" . date( "Y-m-d" ) . "','" . date( "H:i:s" ) . "');"; if ( $conn->query( $sql ) === TRUE ) { session_start(); $_SESSION[ 'member-visit' ] = $_POST[ 'username' ]; setcookie( "date", date( "Y-m-d" ), time() + ( 86400 * 30 ), "/" ); setcookie( "timein", date( "H:i:s" ), time() + ( 86400 * 30 ), "/" ); navigate( 'out.php' ); } else { navigate( 'member-enter.php', $conn->error ); } $conn->close(); } else { navigate( 'member-enter.php?status=fail' ); } $conn->close(); } ?> <?php if ( isset( $_GET[ 'status' ] ) ) { if ( $_GET[ 'status' ] == "success" ) { print( '<script type="text/javascript"> showmessage("Recode successfully Deleted"); </script>' ); } if ( $_GET[ 'status' ] == "fail" ) { print( '<script type="text/javascript"> showmessage("Incorrect Username/Password"); </script>' ); } } if ( isset( $_GET[ 'msg' ] ) ) { echo($_GET[ 'msg' ]); print( '<script type="text/javascript"> showmessage("' . $_GET[ 'msg' ] . '"); </script>' ); } ?> </div> </div> <br /> <!-- Footer --> <footer class="footer text-center text-white fixed-bottom"> <div class="text-center p-0" style="background-color: rgba(0, 0, 0, 0.774)" > Made with ❤️ by HNDIT 2019 batch. </div> </footer> <!-- MDB --> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mdb-ui-kit/3.5.0/mdb.min.js" ></script> </body> </html>