-
Notifications
You must be signed in to change notification settings - Fork 2
/
process.php
76 lines (62 loc) · 1.91 KB
/
process.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
74
75
76
<?php
session_start();
require "vendor/autoload.php";
if (isset($_POST["fname"])) {
$fname = $_POST["fname"];
$lname = $_POST["lname"];
$email = $_POST["email"];
$password = $_POST["password"];
$phoneno = $_POST["phoneno"];
$error_msg;
try {
$m = new MongoDB\Client("mongodb://vinay0410:[email protected]:23725/pizza");
$db = $m->pizza;
$collection = $db->users;
//var_dump($collection);
} catch (Exception $e) {
#die("Caught Exception failed to Connect".$e->getMessage()."\n");
$error_msg = "Couldn't Connect to Database";
$_SESSION["signup-error"] = array(
"fname" => $fname,
"lname" => $lname,
"email" => $email,
"password" => $password,
"phoneno" => $phoneno,
"error_msg" => $error_msg
);
header("Location: .");
}
if (empty($_SESSION["signup-error"])) {
$result_email = $collection->findOne(['email' => $email]);
if (empty($result_email)) {
$document = array(
"fname" => $fname,
"lname" => $lname,
"email" => $email,
"address" => array(),
"password" => $password,
"phoneno" => $phoneno,
);
$collection->insertOne($document);
//echo "Document Inserted Successfully";
$_SESSION["reg-success"] = true;
header("Location: .");
} else {
$error_msg = "Email Address Already Registered";
$_SESSION["signup-error"] = array(
"fname" => $fname,
"lname" => $lname,
"email" => $email,
"address" => array(),
"password" => $password,
"phoneno" => $phoneno,
"error_msg" => $error_msg
);
//echo "Already exists";
header("Location: .");
}
}
} else {
//echo "Access Denied, You, shouldn't be here";
header("Location: .");
}