Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include_once("../vendor/autoload.php");
- session_start();
- if(isset($_SESSION["loggedin"]) && $_SESSION["loggedin"] === true)
- {
- header("location: /mainpage.php");
- exit;
- }
- if (!empty($_POST))
- {
- $username = $_POST["email"];
- $password = $_POST["password"];
- $mng = new MongoDB\Driver\Manager("mongodb://localhost:27017");
- $filter = [
- '_id'=>$username,
- 'password' =>$password
- ];
- $query = new MongoDB\Driver\Query($filter);
- $cursor = $mng->executeQuery('Assignment2.MyUsersCollection', $query);
- foreach($cursor as $row)
- {
- $_SESSION["userid"] = $row->_id;
- $_SESSION["loggedin"] = true;
- header("location: /mainpage.php");
- }
- echo '<script type="text/JavaScript">
- alert("Your UserID or Password is incorrect");
- </script>';
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement