-
Notifications
You must be signed in to change notification settings - Fork 1
/
log.php
73 lines (55 loc) · 1.51 KB
/
log.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<? PHP
session_start();
?>
<html>
<head>
<title> Movie Database </title>
</head>
<?PHP
$_SESSION["loggedInUser"] = $username;
try {
// open connection to MongoDB server
$conn = new Mongo('localhost');
// access database
$db = $conn->test;
// access collection
$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'
}
}
// disconnect from server
$conn->close();
} catch (MongoConnectionException $e) {
die('Error connecting to MongoDB server');
} catch (MongoException $e) {
die('Error: ' . $e->getMessage());
}
$_SESSION["loggedInUser"] = $correct;
?>
<body>
<br>
<center><h1> Welcome to CS348 Login Page </h1></center>
<br>
<form action="page2.php" METHOD="POST">
<label>Username :</label>
<input type="text" Name="username">
<br>
<label>Password :</label>
<input type="password" Name="userPassword">
<br>
<br>
<input type="submit" value="Login">
<br>
</FORM>
</body>
</html>