Skip to content

Commit 7977a01

Browse files
committedFeb 10, 2021
New changes made
1 parent d1c0b6a commit 7977a01

File tree

10 files changed

+282
-15
lines changed

10 files changed

+282
-15
lines changed
 

‎Explore/assets/js/Snackbar.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
function myFunction() {
2+
// Get the snackbar DIV
3+
var x = document.getElementById("snackbar");
4+
5+
// Add the "show" class to DIV
6+
x.className = "show";
7+
8+
// After 3 seconds, remove the show class from DIV
9+
setTimeout(function(){ x.className = x.className.replace("show", ""); }, 3000);
10+
}

‎Explore/index.html ‎Explore/index.php

+28-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
<?php
2+
// session_start
3+
session_start();
4+
5+
// include db connection
6+
include('../config/db.php');
7+
8+
if(isset($_SESSION['email'])) {
9+
10+
$email = $_SESSION['email'];
11+
$getUserDetails = "SELECT * FROM `users` WHERE `email` = '$email'";
12+
$getUserDetailsStatus = mysqli_query($conn,$getUserDetails);
13+
$getUserDetailsRow = mysqli_fetch_assoc($getUserDetailsStatus);
14+
15+
$name = $getUserDetailsRow['name'];
16+
17+
} else {
18+
19+
header('Location: ../index.php?message=Please login first!');
20+
21+
}
22+
?>
123
<!DOCTYPE html>
224
<html>
325

@@ -13,14 +35,14 @@
1335
<link rel="stylesheet" href="assets/css/styles.min.css">
1436
</head>
1537

16-
<body>
38+
<body onload="myFunction()">
1739
<section>
1840
<nav class="navbar navbar-light navbar-expand-md fixed-top" style="font-size: 20px;background: rgba(0,0,0,0.4);">
1941
<div class="container-fluid"><a class="navbar-brand" href="#" style="font-family: 'Titillium Web', sans-serif;font-size: 30px;color: rgb(254,254,254);">LesKollab</a><button data-toggle="collapse" class="navbar-toggler" data-target="#navcol-1"><span class="sr-only">Toggle navigation</span><span class="navbar-toggler-icon"></span></button>
2042
<div
2143
class="collapse navbar-collapse" id="navcol-1">
2244
<ul class="nav navbar-nav ml-auto">
23-
<li class="nav-item"><a class="nav-link active text-danger" href="#" style="margin-right: 1vw;">Trideep Barik&nbsp;<i class="fa fa-user-circle-o"></i></a></li>
45+
<li class="nav-item"><a class="nav-link active text-danger" href="#" style="margin-right: 1vw;"><?=$name?>&nbsp;<i class="fa fa-user-circle-o"></i></a></li>
2446
<li class="nav-item"><a class="nav-link" href="#" style="color: rgb(255,255,251);margin-right: 1vw;">Explore&nbsp;<i class="fa fa-files-o"></i></a></li>
2547
<li class="nav-item"><a class="nav-link" href="#" style="color: rgb(197,189,0);margin-right: 1vw;">Post an Idea&nbsp;<i class="fa fa-lightbulb-o"></i></a></li>
2648
</ul>
@@ -30,6 +52,9 @@
3052
</section>
3153
<div style="width: 100vw;height: auto;background: url(&quot;https://wallpaperaccess.com/full/983279.jpg&quot;) bottom / cover no-repeat;padding-top: 10vh;">
3254
<div class="container" style="width: 100vw;height: auto;margin: 0px;padding: 0px;">
55+
<?php
56+
include("../components/common/messages.php");
57+
?>
3358
<div class="row" style="width: 100vw;margin-top: 0px;">
3459
<div class="col-4" style="padding: 2vw;height: auto;">
3560
<div class="profile-card" style="border-width: 0px;"><img class="rounded-circle profile-pic" src="assets/img/2.jpg">
@@ -153,6 +178,7 @@ <h6 class="text-muted card-subtitle mb-2">#tag1&nbsp; &nbsp;#tag2&nbsp; &nbsp;#t
153178
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
154179
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.2/js/bootstrap.bundle.min.js"></script>
155180
<script src="assets/js/script.min.js"></script>
181+
<script src="assets/js/Snackbar.js"></script>
156182
</body>
157183

158184
</html>

‎assets/js/Snackbar.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
function myFunction() {
2+
// Get the snackbar DIV
3+
var x = document.getElementById("snackbar");
4+
5+
// Add the "show" class to DIV
6+
x.className = "show";
7+
8+
// After 3 seconds, remove the show class from DIV
9+
setTimeout(function(){ x.className = x.className.replace("show", ""); }, 3000);
10+
}

‎components/common/messages.php

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
if(isset($_GET['message'])) {
3+
$message = $_GET['message'];
4+
?>
5+
6+
<style>
7+
/* The snackbar - position it at the bottom and in the middle of the screen */
8+
#snackbar {
9+
visibility: hidden; /* Hidden by default. Visible on click */
10+
min-width: 250px; /* Set a default minimum width */
11+
margin-left: -125px; /* Divide value of min-width by 2 */
12+
background-color: #333; /* Black background color */
13+
color: #fff; /* White text color */
14+
text-align: center; /* Centered text */
15+
border-radius: 2px; /* Rounded borders */
16+
padding: 16px; /* Padding */
17+
position: fixed; /* Sit on top of the screen */
18+
z-index: 1; /* Add a z-index if needed */
19+
left: 50%; /* Center the snackbar */
20+
bottom: 30px; /* 30px from the bottom */
21+
}
22+
23+
/* Show the snackbar when clicking on a button (class added with JavaScript) */
24+
#snackbar.show {
25+
visibility: visible; /* Show the snackbar */
26+
/* Add animation: Take 0.5 seconds to fade in and out the snackbar.
27+
However, delay the fade out process for 2.5 seconds */
28+
-webkit-animation: fadein 0.5s, fadeout 0.5s 2.5s;
29+
animation: fadein 0.5s, fadeout 0.5s 2.5s;
30+
}
31+
32+
/* Animations to fade the snackbar in and out */
33+
@-webkit-keyframes fadein {
34+
from {bottom: 0; opacity: 0;}
35+
to {bottom: 30px; opacity: 1;}
36+
}
37+
38+
@keyframes fadein {
39+
from {bottom: 0; opacity: 0;}
40+
to {bottom: 30px; opacity: 1;}
41+
}
42+
43+
@-webkit-keyframes fadeout {
44+
from {bottom: 30px; opacity: 1;}
45+
to {bottom: 0; opacity: 0;}
46+
}
47+
48+
@keyframes fadeout {
49+
from {bottom: 30px; opacity: 1;}
50+
to {bottom: 0; opacity: 0;}
51+
}
52+
</style>
53+
54+
<div id="snackbar"><?=$message?></div>
55+
56+
<?php
57+
}
58+
?>

‎config/db.php

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
$conn = mysqli_connect("localhost","root","","LesKollab") or die(mysqli_error($conn));
3+
?>

‎index.html ‎index.php

+32-13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
<?php
2+
// session_start
3+
session_start();
4+
5+
// include db connection
6+
include('./config/db.php');
7+
8+
if(isset($_SESSION['email'])) {
9+
header('Location: ./Explore/index.php?message=You have logged in successfully!');
10+
}
11+
?>
112
<!DOCTYPE html>
213
<html>
314

@@ -13,10 +24,13 @@
1324
<link rel="stylesheet" href="assets/css/styles.css">
1425
</head>
1526

16-
<body>
27+
<body onLoad = "myFunction()">
1728

1829
<nav class="navbar navbar-light navbar-expand-md fixed-top" style="height: 10vh;background: rgba(255,255,255,0.18);">
1930
<div class="container-fluid"><a class="navbar-brand" href="#" style="font-size: 30px;font-family: Aclonica, sans-serif;">LesKollab</a><button data-toggle="collapse" class="navbar-toggler" data-target="#navcol-1"><span class="sr-only">Toggle navigation</span><span class="navbar-toggler-icon"></span></button>
31+
<?php
32+
include("components/common/messages.php");
33+
?>
2034
<div
2135
class="collapse navbar-collapse" id="navcol-1">
2236
<ul class="nav navbar-nav ml-auto">
@@ -31,15 +45,15 @@
3145
<h2>Have Some Pending Projects?</h2>
3246
<i><h5>Need Someone's help to complete it?</h5> <br>
3347
<p>Ideas reshape the world, but there's always a staring and learning point.<br> It's time to redefine the way we learn.</p>
34-
Learnt a new skill, but have no one to work on a starting project with?<br>
48+
Learnt a new skill, but have no one to work on a starting project with?<br>
3549
Thought of an idea but don't have the necessar tech stacks?<br>
36-
Search for people to collaborate with, or propose a project and let collaborators find you.<br/>
50+
Search for people to collaborate with, or propose a project and let collaborators find you.<br/>
3751
With LesKollab, it's time to implement and learn things on the get go, but not alone anymore!</p></i>
3852
<br><br><br><br>
3953
<button type="button" class="btn btn-outline-warning" style="height: 10vh;width:27vw;font-size:1.5em;">Find a Project Partner</button>
4054

4155
</div>
42-
56+
4357
</div>
4458

4559
<div class="modal fade bd-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
@@ -56,42 +70,46 @@ <h2>Have Some Pending Projects?</h2>
5670
<button data-target="#carouselExampleIndicators" data-slide-to="1" type="button" class="btn btn-outline-warning btn-lg">Register</button>
5771
<div class="carousel-inner">
5872
<div class="carousel-item active">
59-
<form>
73+
<form action = "./scripts/Login.php" method="post">
6074
<div class="form-group">
6175
<br>
6276
<label for="exampleInputEmail1">Email address</label>
63-
<input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter email">
77+
<input type="email" class="form-control" name = "email" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter email">
6478
<small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small>
6579
</div>
6680
<div class="form-group">
6781
<label for="exampleInputPassword1">Password</label>
68-
<input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
82+
<input type="password" class="form-control" name = "password" id="exampleInputPassword1" placeholder="Password">
6983
</div>
7084
<br>
7185
<button type="submit" class="btn btn-primary">Submit</button>
7286
</form>
7387
</div>
7488
<div class="carousel-item">
75-
<form>
89+
<form action = "./scripts/Register.php" method = "post">
7690
<div class="form-group">
7791
<br>
7892
<label for="exampleInputEmail1">Email address</label>
79-
<input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter email">
93+
<input type="email" class="form-control" name = "email" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter email">
8094
<small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small>
8195
</div>
96+
<div class="form-group">
97+
<label for="exampleInputPassword1">Name</label>
98+
<input type="text" class="form-control" name = "name" id="exampleInputPassword1" placeholder="Your name">
99+
</div>
82100
<div class="form-group">
83101
<label for="exampleInputPassword1">Password</label>
84-
<input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
102+
<input type="password" class="form-control" name = "password" id="exampleInputPassword1" placeholder="Password">
85103
</div>
86104
<div class="form-group">
87105
<br>
88106
<label for="exampleInputEmail1">GitHub</label>
89-
<input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter email">
107+
<input type="text" class="form-control" name = "github" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter github profile link">
90108
</div>
91109
<div class="form-group">
92110
<br>
93111
<label for="exampleInputEmail1">LinkedIn</label>
94-
<input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter email">
112+
<input type="text" class="form-control" name = "linkedin" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter linkedin profile link">
95113
</div>
96114
<br>
97115
<button type="submit" class="btn btn-primary">Submit</button>
@@ -107,11 +125,12 @@ <h2>Have Some Pending Projects?</h2>
107125
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
108126
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.2/js/bootstrap.bundle.min.js"></script>
109127
<script src="assets/js/Button-Ripple-Effect-Animation-Wave-Pulse.js"></script>
128+
<script src="assets/js/Snackbar.js"></script>
110129
<script>
111130
$('#myModal').on('shown.bs.modal', function () {
112131
$('#myInput').trigger('focus')
113132
})
114133
</script>
115134
</body>
116135

117-
</html>
136+
</html>

‎logout.php

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
session_start();
3+
session_unset($_SESSION['email']);
4+
session_destroy();
5+
header('Location: ./index.php?message=You have logged out successfully!');
6+
?>

‎scripts/Login.php

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
// session start
4+
session_start();
5+
6+
// include db connection
7+
include('./db.php');
8+
9+
// declare variables
10+
$email = "";
11+
$password = "";
12+
13+
// get form data
14+
if(isset($_POST['email'])) {
15+
$email = $_POST['email'];
16+
}
17+
18+
if(isset($_POST['password'])) {
19+
$password = $_POST['password'];
20+
}
21+
22+
if($email != "" && $password != "") { // if the fields are not empty!
23+
24+
// check user!
25+
$checkUser = "SELECT * FROM `users` WHERE `email` = '$email'";
26+
$checkUserStatus = mysqli_query($conn,$checkUser) or die(mysqli_error($conn));
27+
$checkUserRow = mysqli_fetch_assoc($checkUserStatus);
28+
29+
if(mysqli_num_rows($checkUserStatus) > 0) { // if user exists!
30+
31+
$dbPassword = $checkUserRow['password'];
32+
$salt = $checkUserRow['salt'];
33+
34+
$newPassword = md5(md5($password.$salt));
35+
36+
if($newPassword == $dbPassword) { // password matches with db!
37+
38+
$_SESSION['email'] = $email;
39+
header('Location: ../Explore/index.php?message=Logged in successfully!');
40+
41+
} else { // if password is incorrect!
42+
43+
header('Location: ../index.php?message=The password is incorrect!');
44+
45+
}
46+
47+
} else {
48+
49+
header('Location: ../index.php?message=Sorry user doesnt exist! Please Register!');
50+
51+
}
52+
53+
} else { // if the fields are empty!
54+
55+
header('Location: ../index.php?message=Please fill the form properly!');
56+
57+
}
58+
?>

0 commit comments

Comments
 (0)
Please sign in to comment.