-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
218 lines (208 loc) · 7.85 KB
/
index.php
File metadata and controls
218 lines (208 loc) · 7.85 KB
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
<?php
session_start();
include 'essentials/_dbconnect.php';
//signup code
if($_SERVER['REQUEST_METHOD']=='POST')
{
$sameUserName=false;
$incorrectPassword=false;
if(isset($_POST['signup']))
{
$username=$_POST['username'];
$username=str_replace("<","<",$username);
$username=str_replace(">",">",$username);
$username=str_replace("'","''",$username);
$password=$_POST['password'];
$password=str_replace("<","<",$password);
$password=str_replace(">",">",$password);
$password=str_replace("'","''",$password);
$rpassword=$_POST['rpassword'];
$rpassword=str_replace("<","<",$rpassword);
$rpassword=str_replace(">",">",$rpassword);
$rpassword=str_replace("'","''",$rpassword);
$sql="SELECT * FROM `userdetails` WHERE `USERNAME`='$username'";
$result=mysqli_query($connect,$sql);
$num_rows_selected=mysqli_num_rows($result);
if($num_rows_selected==1)
{
$sameUserName=true;
}
else
{
if($password==$rpassword)
{
$hashPassword=password_hash($password,PASSWORD_DEFAULT);
$sql="INSERT INTO `userdetails`( `USERNAME`, `PASSWORD`) VALUES ('$username','$hashPassword')";
$result=mysqli_query($connect,$sql);
}
else
{
$incorrectPassword=true;
}
}
}
}
// login code
if($_SERVER['REQUEST_METHOD']=='POST')
{
$loginUser=true;
if(isset($_POST['login']))
{
$lusername=$_POST['lusername'];
$lusername=str_replace("<","<",$lusername);
$lusername=str_replace(">",">",$lusername);
$lusername=str_replace("'","''",$lusername);
$lpassword=$_POST['lpassword'];
$lpassword=str_replace("<","<",$lpassword);
$lpassword=str_replace(">",">",$lpassword);
$lpassword=str_replace("'","''",$lpassword);
$sql="SELECT * FROM `userdetails` WHERE `USERNAME`='$lusername'";
$result=mysqli_query($connect,$sql);
$num=mysqli_num_rows($result);
if($num==1)
{
$row=mysqli_fetch_assoc($result);
if(password_verify($lpassword,$row['PASSWORD']))
{
$loginUser=true;
$_SESSION['loggedin']=true;
$_SESSION['username']=$row['USERNAME'];
header("location:index.php");
}
else
{
$loginUser=false;
}
}
else
{
$loginUser=false;
}
}
}
?>
<!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/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
<link rel="stylesheet" href="a.css">
<!-- icon link -->
<link rel="icon" href="images/forumlogo.png" type="image/icon type">
<title>MyForum</title>
</head>
<body>
<?php
include 'essentials/_header.php';
if(isset($sameUserName)){
if($sameUserName){
echo('<div class="alert alert-danger alert-dismissible fade show" role="alert">
<strong>Username already present!</strong> Try some other username.
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>');
}
}
if(isset($incorrectPassword)){
if($incorrectPassword){
echo('<div class="alert alert-danger alert-dismissible fade show" role="alert">
<strong>Passwords don\'t match!</strong> Re-enter the password correctly.
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>');
}
}
if(isset($incorrectPassword)&&isset($sameUserName)){
if($incorrectPassword==false&& $sameUserName==false){
echo('<div class="alert alert-success alert-dismissible fade show" role="alert">
<strong>Account createrd successfully!</strong>Now login to continue.
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>');
}
}
if(isset($loginUser)){
if(!$loginUser){
echo('<div class="alert alert-danger alert-dismissible fade show" role="alert">
<strong>Invalid credentials!</strong>Try to login again.
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>');
}
}
?>
<!-- <div id="carouselExampleIndicators" mt-0 class="carousel slide" data-bs-ride="carousel">
<div class="carousel-indicators">
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="0" class="active"
aria-current="true" aria-label="Slide 1"></button>
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="1"
aria-label="Slide 2"></button>
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="2"
aria-label="Slide 3"></button>
</div>
<div class="carousel-inner">
<div class="carousel-item active">
<img src="images/slider/1.jpg
" class="d-block w-100" style="height: 500px; width=100%;">
</div>
<div class="carousel-item">
<img src="images/slider/2.jpg" style="height: 500px;width=100%;" class="d-block w-100">
</div>
<div class="carousel-item">
<img src="images/slider/3.jpg" style="height: 500px;width=100%;" class="d-block w-100">
</div>
</div>
<button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleIndicators"
data-bs-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="visually-hidden">Previous</span>
</button>
<button class="carousel-control-next" type="button" data-bs-target="#carouselExampleIndicators"
data-bs-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="visually-hidden">Next</span>
</button>
</div>
<div class="container">
<p class="text-white bg-dark container my-3 rounded text-center">CATEGORIES</p>
</div> -->
<div class="catalog">
<?php
$sql="SELECT * FROM `categories`";
$result=mysqli_query($connect,$sql);
while($row=mysqli_fetch_assoc($result))
{
$title=$row['TITLE'];
$description=$row['DESCRIPTION'];
echo ' <div class="main">
<a href="threadlist.php?ID='.$row['ID'].'" style="text-decoration: none; color: white;">
<div class="glassdiv">
<div class="card-body">
<img src="cardImages/'.$title.'.png" height=100px style="border-radius: 5px;">
<h5 class="card-title">'.$title.'</h5>
<button class="thread-button">View thread</button>
</div>
</div></a>
</div>';
}
?>
</div>
<ul class="circles">
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
<!-- <?php
include 'essentials/_footer.php';
?> -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/js/bootstrap.bundle.min.js"
integrity="sha384-gtEjrD/SeCtmISkJkNUaaKMoLD0//ElJ19smozuHV6z3Iehds+3Ulb9Bn9Plx0x4" crossorigin="anonymous">
</script>
</body>
</html>