-
Notifications
You must be signed in to change notification settings - Fork 1
/
registration.php
118 lines (100 loc) · 5.47 KB
/
registration.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
require 'vendor/autoload.php';
$client = new MongoDB\Client;
$ecommerce = $client->ecommerce;
$customer = $ecommerce->customer;
?>
<?php
if (isset($_POST['registerbutton'])) {
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$usercontactnumber = $_POST['usercontactnumber'];
$useremail = $_POST['useremail'];
$userpassword = $_POST['userpassword'];
$useraddress = $_POST['useraddress'];
$samecount = 0;
$isUserExist = $customer->findOne([
"email" => $useremail
]);
if($isUserExist == null){
// Register Karo
// Get Last Inserted Id
$lastDocument = $customer->findOne(
[],
[
'limit' => 1,
'sort' => ['_id' => -1]
]
);
$lastInsertedId = $lastDocument->_id;
$customer->insertOne([
"_id" => $lastInsertedId + 1,
"name" => $firstname,
"surname" => $lastname,
"email" => $useremail,
"password" => $userpassword,
"address" => $useraddress,
"contact_info" => $usercontactnumber
]);
echo '<div class="alert alert-success">User registered successfully, <a href="./">Click Here</a> To Go To Homepage.</div>';
} else {
echo '<div class="alert alert-danger">That email is already taken . Try again with a different one or try logging in again</div>';
}
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
<title>Hello, world!</title>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-sm-3 "></div>
<div class="col-sm-6 mt-5">
<br><br>
<br><br>
<div class="card text-dark bg-light mb-3 ">
<div class="card-header"><b>User Registration</b></div>
<div class="card-body">
<form action="" method="POST">
<div class="input-group mb-3">
<span class="input-group-text bg-light" id="inputGroup-sizing-default">First Name </span>
<input type="text" class="form-control" name="firstname" aria-label="Sizing example input" aria-describedby="inputGroup-sizing-default" required>
</div>
<div class="input-group mb-3">
<span class="input-group-text bg-light" id="inputGroup-sizing-default">Last Name </span>
<input type="text" class="form-control" name="lastname" aria-label="Sizing example input" aria-describedby="inputGroup-sizing-default" required>
</div>
<div class="input-group mb-3">
<span class="input-group-text bg-light" id="inputGroup-sizing-default">Email </span>
<input type="email" class="form-control" name="useremail" aria-label="Sizing example input" aria-describedby="inputGroup-sizing-default" required>
</div>
<div class="input-group mb-3">
<span class="input-group-text bg-light" id="inputGroup-sizing-default">Password</span>
<input type="password" class="form-control" name="userpassword" aria-label="Sizing example input" aria-describedby="inputGroup-sizing-default" required>
</div>
<div class="input-group mb-3">
<span class="input-group-text bg-light" id="inputGroup-sizing-default">Address </span>
<input type="text" class="form-control" name="useraddress" aria-label="Sizing example input" aria-describedby="inputGroup-sizing-default" required>
</div>
<div class="input-group mb-3">
<span class="input-group-text bg-light" id="inputGroup-sizing-default">Contact Number </span>
<input type="text" class="form-control" name="usercontactnumber" aria-label="Sizing example input" aria-describedby="inputGroup-sizing-default" required>
</div>
<div class="input-group mb-3 col-lg-6">
<input type="submit" class="btn btn-success btn-block" name="registerbutton" value="Register">
</div>
</form>
</div>
</div>
</div>
<div class="col-sm-4"></div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-gtEjrD/SeCtmISkJkNUaaKMoLD0//ElJ19smozuHV6z3Iehds+3Ulb9Bn9Plx0x4" crossorigin="anonymous"></script>
</body>
</html>