-
Notifications
You must be signed in to change notification settings - Fork 8
/
index.php
262 lines (211 loc) · 7.8 KB
/
index.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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
<?php
session_start();
include 'config.php';
if(isset($_POST['login'])){
// echo "<script type='text/javascript'>alert('check');</script>";
if($_SERVER["REQUEST_METHOD"] == "POST") {
// username and password sent from form
$myusername = mysqli_real_escape_string($conn,$_POST['uname']);
$mypassword = mysqli_real_escape_string($conn,$_POST['pass']);
$sql = "SELECT farmerID FROM farmer WHERE name = '$myusername' and password = '$mypassword'";
$result = mysqli_query($conn,$sql);
$row = mysqli_fetch_array($result,MYSQLI_ASSOC);
$active = $row['active'];
$count = mysqli_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count == 1) {
// session_register("$myusername");
$_SESSION['login_user'] = $myusername;
header("location: home.php");
exit();
}
else {
$error = "Your Login Name or Password is invalid";
echo "<script type='text/javascript'>alert('$error');</script>";
}
}
}
if(isset($_POST['register'])){
$farmerNIC=$_POST['farmerNIC'];
$farmerName=$_POST['farmerName'];
$farmerMobile=$_POST['farmerMobile'];
$farmerPs=$_POST['farmerPs'];
$farmerConPs=$_POST['farmerConPs'];
$farmerAgriDiv=$_POST['farmerAgriDiv'];
if ($farmerPs==$farmerConPs) {
if(! $conn ) {
die('Could not connect: ' . mysql_error());
echo "<script type='text/javascript'>alert('Could not connect');</script>";
}
$sql = "INSERT INTO farmer (NIC,name,mobile,password,agriDiv) VALUES ('$farmerNIC','$farmerName','$farmerMobile','$farmerPs','$farmerAgriDiv')";
if ($conn->query($sql) === TRUE) {
echo "<script type='text/javascript'>alert('SQL DONE');</script>";
mysqli_close($conn);
$_SESSION['login_user'] = $farmerName;
header("Location:home.php");
exit;
}
else {
echo "Error: " . $sql . "<br>" . $conn->error;
echo "<script type='text/javascript'>alert('SQL FAIL');</script>";
}
}
else{
echo "<script type='text/javascript'>alert('Password doesn't match');</script>";
}
}
?>
<link href="css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<link href="css/style.css" rel="stylesheet">
<script src="js/bootstrap.min.js"></script>
<script src="js/jquery-3.2.1.min.js"></script>
<!DOCTYPE html>
<html lang="en">
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<header>
<div class="container">
<div class="row">
<div class="col-sm-6">
<!-- <div class="logo">Responsive</div> -->
<div class="header-logo">
<a class="site-logo" href="index.html">
<img src="img/logo.png" alt="Homepage">
</a>
</div>
</div>
<div class="col-sm-6 hidden-xs">
<div class="background1">
<style>
body{
background-image:url('img/bg.jpg');
background-repeat: no-repeat;
background-size: cover;
backface-visibility: (50%);
}
</style>
</div>
<form class="login-form" method="POST">
<div class="row">
<div class="col-sm-5">
<div class="form-group">
<input type="text" name="uname" class="form-control" placeholder="User name">
<div class="login-bottom-text checkbox hidden-sm">
<label>
<input type="checkbox" id="">
Keep me sign in
</label>
</div>
</div>
</div>
<div class="col-sm-5">
<div class="form-group">
<input type="text" name="pass" class="form-control" placeholder="Password" required>
<div class="login-bottom-text hidden-sm"> Forgot your password? </div>
</div>
</div>
<div class="col-sm-2">
<div class="form-group">
<button type="submit" name ="login" value="login" class="btn btn-primary" required>Login</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</header>
<section id="home" class="s-home target-section" data-natural-width=3000 data-natural-height=2000 data-position-y=center>
<div class="overlay"></div>
<div class="shadow-overlay"></div>
<article class="container">
<div class="row">
<div class="col-sm-8">
</div>
<div class="col-sm-4">
<div class="">
<h3><i class="fa fa-shield"></i><br>Create a new account</h3>
<small>It's free and always will be</small>
<hr>
<form method="POST">
<!-- <div class="form-group">
<label class="control-label" for=""></label>
<input type="text" name="farmerID" required class="form-control" placeholder="NIC">
</div> -->
<div class="form-group">
<label class="control-label" for=""></label>
<input type="text" name="farmerNIC" required class="form-control" placeholder="NIC">
</div>
<div class="form-group">
<label class="control-label" for=""></label>
<input type="text" name="farmerName" required class="form-control" placeholder="Name">
</div>
<!-- <div class="form-group">
<label class="control-label" for=""></label>
<input type="text" name="farmerAgriDiv" required class="form-control" placeholder="Agriculture Division">
</div> -->
<div class="form-group">
<select class="form-control" name="farmerAgriDiv" placeholder="Select Division">
<?php
$getDivision = "SELECT divName from divisionname order by ID";
$result = $conn->query($getDivision);
if ($result->num_rows > 0)
{
while ($row = $result->fetch_assoc())
{
echo "<option value='".$row['divName']."'>".$row['divName']."</option>";
}
}
?>
</select>
</div>
<div class="form-group">
<label class="control-label" for=""></label>
<input type="text" name="farmerMobile" required class="form-control" placeholder="Mobile">
</div>
<div class="form-group">
<label class="control-label" for=""></label>
<input type="password" name="farmerPs" required class="form-control" placeholder="Password">
</div>
<div class="form-group">
<label class="control-label" for=""></label>
<input type="password" name="farmerConPs" required class="form-control" placeholder="Repeat Password">
</div>
<small>
By clicking Create Account, you agree to our Terms and confirm that you have read our Data Policy, including our Cookie Use Policy. You may receive SMS message notifications from Facebook and can opt out at any time.
</small>
<div style="height:10px;"></div>
<div class="form-group">
<label class="control-label" for=""></label>
<button type="submit" name="register" class="btn btn-primary" value="register">Submit</button>
</div>
</form>
<?php
?>
</div>
</div>
</div>
</article>
</section>
<footer class="container">
<hr>
<div class="footer-options">
<ul >
<li><a href="#">Mobile</li>
<li><a href="#">Find Friends</li>
<li><a href="#">Badges</li>
<li><a href="#">People</li>
<li><a href="#">Pages</li>
<li><a href="#">Places</a></li>
<li><a href="#">Games</a></li>
<li><a href="#">Locations</a></li>
<li><a href="#">About</a></li>
</ul>
</div>
<div style="clear:both"></div>
<small class="copyrights"> © Copyrights reserved 2018</small>
</section>