-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathngo_reg.php
235 lines (199 loc) · 8.34 KB
/
ngo_reg.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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
<?php
require_once "config.php";
$username = $password = $confirm_password = $reg_id = $phone = $a_phone = $website = $email = $address = $area = $pin = "";
$username_err = $password_err = $confirm_password_err = "";
if ($_SERVER['REQUEST_METHOD'] == "POST"){
// Check if username is empty
if(empty(trim($_POST["username"]))){
$username_err = "Username cannot be blank";
}
else{
$sql = "SELECT id FROM ngo WHERE username = ?";
$stmt = mysqli_prepare($conn, $sql);
if($stmt)
{
mysqli_stmt_bind_param($stmt, "s", $param_username);
// Set the value of param username
$param_username = trim($_POST['username']);
// Try to execute this statement
if(mysqli_stmt_execute($stmt)){
mysqli_stmt_store_result($stmt);
if(mysqli_stmt_num_rows($stmt) == 1)
{
$username_err = "This username is already taken";
}
else{
$username = trim($_POST['username']);
}
}
else{
echo "Something went wrong";
}
}
}
// mysqli_stmt_close($stmt);
// Check for password
if(empty(trim($_POST['password']))){
$password_err = "Password cannot be blank";
}
elseif(strlen(trim($_POST['password'])) < 5){
$password_err = "Password cannot be less than 5 characters";
}
else{
$password = trim($_POST['password']);
}
// Check for confirm password field
if(trim($_POST['password']) != trim($_POST['confirm_password'])){
$password_err = "Passwords should match";
}
// reg_id
$reg_id = trim($_POST['reg_id']);
// phone no
$phone = trim($_POST['phone']);
$a_phone = trim($_POST['a_phone']);
// email
$email = trim($_POST['email']);
// website
$website = trim($_POST['website']);
// address
$address = trim($_POST['address']);
// area
if(isset($_POST["area"])){
$area = $_POST['area'];
echo $area;
}
// pin
$pin = trim($_POST['pin']);
// If there were no errors, go ahead and insert into the database
if(empty($username_err) && empty($password_err) && empty($confirm_password_err))
{
$sql = "INSERT INTO ngo (username, password, reg_id, phone, a_phone, website, email, address, area, pin) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
$stmt = mysqli_prepare($conn, $sql);
if ($stmt)
{
mysqli_stmt_bind_param($stmt, "ssssssssss", $param_username, $param_password, $reg_id, $phone, $a_phone, $website, $email, $address, $area, $pin);
// Set these parameters
$param_username = $username;
$param_password = password_hash($password, PASSWORD_DEFAULT);
// Try to execute the query
if (mysqli_stmt_execute($stmt))
{
header("location: ngo_login.php");
}
else{
echo "Something went wrong... cannot redirect!";
}
}
mysqli_stmt_close($stmt);
}
mysqli_close($conn);
}
?>
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="login-register\register.css">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<title>PHP login system!</title>
</head>
<body>
<!-- <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<a class="navbar-brand" href="#">Php Login System</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNavDropdown">
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="register.php">Register</a>
</li>
<li class="nav-item">
<a class="nav-link" href="login.php">Login</a>
</li>
<li class="nav-item">
<a class="nav-link" href="logout.php">Logout</a>
</li>
</ul>
</div>
</nav> -->
<div class="container mt-5">
<h3>Please Register Here:</h3>
<hr>
<form action="" method="post">
<div class="form-row">
<div class="form-group col-md-6">
<label for="inputEmail4">Username *</label>
<input type="text" class="form-control" name="username" id="inputEmail4" placeholder="Enter Name of your Organization" Required="true">
</div>
<div class="form-group col-md-6">
<label for="inputRegid">Registration ID *</label>
<input type="text" class="form-control" name ="reg_ig" id="reg_id" placeholder="Enter Registration ID of your Organization" Required="true">
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="inputEmail">Email *</label>
<input type="email" class="form-control" name ="email" id="inputEmail" placeholder="Enter Email" Required="true">
</div>
<div class="form-group col-md-3">
<label for="inputEmail4">Contact No. *</label>
<input type="tel" minlength="10" maxlength="10" class="form-control" name="phone" id="inputPhone" placeholder="Enter Contact no." Required="true">
</div>
<div class="form-group col-md-3">
<label for="inputEmail4">Alternate Contact No.</label>
<input type="tel" minlength="10" maxlength="10" class="form-control" name="a_phone" id="inputPhone" placeholder="Enter Contact no.">
</div>
</div>
<div class="form-group">
<label for="inputURL">Website *</label>
<input type="url" class="form-control" name ="website" id="inputUrl" placeholder="Enter Website URL" Required="true">
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="inputPassword4">Password *</label>
<input type="password" minlength="8" class="form-control" name ="password" id="inputPassword4" placeholder="Enter Password" Required="true">
</div>
<div class="form-group col-md-6">
<label for="inputPassword4">Confirm Password *</label>
<input type="password" minlength="8" class="form-control" name ="confirm_password" id="inputPassword" placeholder="Confirm Password" Required="true">
</div>
</div>
<div class="form-group">
<label for="inputAddress2">Address *</label>
<input type="text" class="form-control" name="address" id="inputAddress2" placeholder="Enter Address" Required="true">
</div>
<div class="form-row">
<div class="form-group col-md-4">
<label for="area" Required="true">Area *</label>
<select id="area" class="form-control" name="area" Required="true">
<!-- <option selected></option> -->
<option>Mumbai Suburban</option>
<option>Mumbai Western</option>
<option>Mumbai Eastern</option>
<option>South Mumbai</option>
<option>District Thane</option>
<option>Navi Mumbai</option>
</select>
</div>
<div class="form-group col-md-2">
<label for="inputZip">Pin Code *</label>
<input type="tel" minlength="6" maxlength="6" class="form-control" name="pin" id="pin" Required="true">
</div>
</div>
<button type="submit">Register</button>
</form>
</div>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>
</html>