Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try {
- // open connection to MongoDB server
- $conn = new MongoClient("mongodb://locidol:locidol@127.0.0.1:27017/quochoi_db");
- // access database
- $db = $conn->quochoi_db;
- // access collection
- $collection = $db->users;
- $username = $_POST['username'];
- $password = $_POST['password'];
- $user = $collection->find(array('user'=> $username, 'pwd'=> $password));
- foreach ($user as $doc) {
- if (empty($doc)){
- break;
- }
- $_SESSION["username"] = $doc['user'];
- echo "<script>window.location='./manager.php'</script>";
- die();
- }
- // disconnect from server
- $conn->close();
- } catch (MongoConnectionException $e) {
- die('Error connecting to MongoDB server');
- } catch (MongoException $e) {
- die('Error: ' . $e->getMessage());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement