-
Notifications
You must be signed in to change notification settings - Fork 1
/
submit.php
46 lines (30 loc) · 988 Bytes
/
submit.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<? PHP
session_start();
?>
<?PHP
$_SESSION["loggedInUser"] = $username;
try {
$conn = new Mongo('localhost');
$db = $conn->test;
$collection = $db->items;
$userName = $_POST['username'];
$userPass = $_POST['userPassword'];
$user = $db->$collection->findOne(array('username'=> 'user1', 'password'=> 'pass1'));
foreach ($user as $obj) {
echo 'Username' . $obj['username'];
echo 'password: ' . $obj['password'];
if($userName == 'user1' && $userPass == 'pass1'){
echo 'found'
}
else{
echo 'not found'
}
}
$conn->close();
} catch (MongoConnectionException $e) {
die('Error connecting to MongoDB server');
} catch (MongoException $e) {
die('Error: ' . $e->getMessage());
}
$_SESSION["loggedInUser"] = $correct;
?>