-
Notifications
You must be signed in to change notification settings - Fork 56
/
index.php
226 lines (185 loc) · 7.89 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
<?php session_start();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="SHORTCUT ICON" href="images/fibble.png" type="image/x-icon" />
<link rel="ICON" href="images/fibble.png" type="image/ico" />
<title>Fibble - Decentralized Application</title>
<!-- Bootstrap -->
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/all.css">
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/mdb.min.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
</head>
<body class="violetgradient">
<?php
if( !isset($_SESSION['role']) ){
?>
<center>
<div class="customalert">
<div class="alertcontent">
<div id="alertText">   </div>
<img id="qrious">
<div id="bottomText" style="margin-top: 10px; margin-bottom: 15px;">   </div>
<button id="closebutton" class="formbtn"> OK </button>
</div>
</div>
</center>
<div style="width: 100%">
<center>
<div class="loginformcard" id="card1">
<h4> Welcome to Fibble - The Supply Chain DAPP</h4>
<p style="max-width: 80%;">
Fibble is a Decentralized E2E Logistics Application that stores the whereabouts of product at every freight hub on the Blockchain. At consumer end, customers can simply scan the QR CODE of products and get complete information about the provenance of that product hence empowering consumers to only purchase authentic and quality products.
</p>
<div class="cardbtnarea">
<button class="col-md-5 rolebtn" id="login">Login</button>
<button class="col-md-5 rolebtn" id="signup">Signup</button>
</div>
</div>
<div class="loginformcard" id="maincard3">
<h4> Create your new account</h4>
<form style="margin-top: 30px; margin-bottom: 30px;" action="registration.php" method="POST" onsubmit="return checkSecondForm(this);">
<label type="text" class="formlabel"> Email </label>
<input type="text" class="forminput" name="email" id="email" onkeypress="isNotChar(event)" required>
<label type="text" class="formlabel" style="margin-top: 10px;"> Userame </label>
<input type="text" class="forminput" name="username" id="username" onkeypress="blockSpaces(event)" required>
<label type="text" class="formlabel" style="margin-top: 10px;"> Password </label>
<input type="password" class="forminput" name="pw" id="pw" onkeypress="isNotChar(event)" required>
<label type="text" class="formlabel" style="margin-top: 10px;"> Confirm Password </label>
<input type="password" class="forminput" name-"cpw" id="cpw" onkeypress="isNotChar(event)" required>
<label type="text" class="formlabel" style="margin-top: 10px;"> Select Your Role </label>
<select class="formselect" name="role">
<option value="2">Consumer</option>
<option value="1">Retailer</option>
<option value="1">Distributor</option>
<option value="0">Manufacturer</option>
</select>
<button class="formbtn" name="loginsubmit" value="submitted!" type="submit">Register</button>
<br>
<a href="#" id="gotologin"> Already have an account? Login to your existing account </a>
</form>
</div>
<div class="loginformcard" id="maincard2">
<h4> Login to your existing account</h4>
<form style="margin-top: 30px; margin-bottom: 30px;" action="login.php" method="POST" onsubmit="return checkFirstForm(this);">
<label type="text" class="formlabel"> Email </label>
<input type="text" class="forminput" name="email" id="email" onkeypress="isNotChar(event)" required>
<label type="text" class="formlabel" style="margin-top: 10px;"> Password </label>
<input type="password" class="forminput" name="pw" id="pw" onkeypress="isNotChar(event)" required>
<button class="formbtn" name="loginsubmit" type="submit">Login</button>
<br>
<a href="#" id="gotosignup"> Don't have an account? Create a new account now</a>
</form>
</div>
</center>
</div>
<?php
}else{
include 'redirection.php';
redirect('checkproduct.php');
}
?>
<!-- JQuery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!-- Material Design Bootstrap-->
<script type="text/javascript" src="js/popper.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/mdb.min.js"></script>
<script>
function isInputNumber(evt){
var ch = String.fromCharCode(evt.which);
if(!(/[0-9]/.test(ch))){
evt.preventDefault();
}
}
function isNotChar(evt){
var ch = String.fromCharCode(evt.which);
if(ch=="'"){
evt.preventDefault();
}
}
function blockSpaces(evt){
var ch = String.fromCharCode(evt.which);
if(ch=="'" || ch==" "){
evt.preventDefault();
}
}
function blockSpecialChar(e){
var k;
document.all ? k = e.keyCode : k = e.which;
return ((k >= 64 && k < 91) || (k > 96 && k < 123) || k == 8 || k == 46|| k == 42|| k == 33 || k == 32 || (k >= 48 && k <= 57));
}
$("#login").on("click", function(){
$("#card1").hide("fast","linear");
$("#maincard3").hide("fast","linear");
$("#maincard2").show("fast","linear");
});
$("#gotologin").on("click", function(){
$("#card1").hide("fast","linear");
$("#maincard3").hide("fast","linear");
$("#maincard2").show("fast","linear");
});
$("#openlogin").on("click", function(){
$("#card1").hide("fast","linear");
$("#maincard3").hide("fast","linear");
$("#maincard2").show("fast","linear");
});
$("#signup").on("click", function(){
$("#card1").hide("fast","linear");
$("#maincard2").hide("fast","linear");
$("#maincard3").show("fast","linear");
});
$("#gotosignup").on("click", function(){
$("#card1").hide("fast","linear");
$("#maincard2").hide("fast","linear");
$("#maincard3").show("fast","linear");
});
$("#opensignup").on("click", function(){
$("#card1").hide("fast","linear");
$("#maincard2").hide("fast","linear");
$("#maincard3").show("fast","linear");
});
$("#closebutton").on("click", function(){
$(".customalert").hide("fast","linear");
});
function checkSecondForm(theform){
var email = theform.email.value;
var pw = theform.pw.value;
var cpw = theform.cpw.value;
if (!validateEmail(email)) {
showAlert("Invalid Email address");
return false;
}
if (pw!=cpw) {
showAlert("Please check your password");
return false;
}
return true;
}
function checkFirstForm(theform){
var email = theform.email.value;
if (!validateEmail(email)) {
showAlert("Invalid Email address");
return false;
}
return true;
}
function showAlert(message){
$("#alertText").html(message);
$("#qrious").hide();
$("#bottomText").hide();
$(".customalert").show("fast","linear");
}
function validateEmail(email) {
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(email);
}
</script>
</body>
</html>
<!-- Developed by Anubhav Dutta : https://www.linkedin.com/in/iamanubhavdutta/ -->