Skip to content

Commit adf28a2

Browse files
committedNov 3, 2018
Init
0 parents  commit adf28a2

File tree

8 files changed

+160
-0
lines changed

8 files changed

+160
-0
lines changed
 

‎bootstrap.php

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!-- Latest compiled and minified CSS -->
2+
<link rel="stylesheet" href="https://bootswatch.com/4/materia/bootstrap.min.css">
3+
4+
<!-- jQuery library -->
5+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
6+
7+
<!-- Popper JS -->
8+
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
9+
10+
<!-- Latest compiled JavaScript -->
11+
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>

‎conn.php

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
define("DB_HOST","localhost");
3+
define("DB_USERNAME","root");
4+
define("DB_NAME","shuttergram");
5+
define("DB_PASSWORD","");
6+
7+
$conn = mysqli_connect(DB_HOST,DB_USERNAME,DB_PASSWORD,DB_NAME);
8+
9+
?>

‎index.css

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.container{
2+
opacity: 0.8;
3+
position: absolute;
4+
top : 50%;
5+
transform: translate(-50%,-50%);
6+
left : 50%;
7+
}
8+
9+
body{
10+
background: url("login.jpg");
11+
background-size: cover;
12+
}

‎index.php

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<link rel="stylesheet" href="index.css">
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
8+
<title>Login</title>
9+
<?php require("bootstrap.php");
10+
require("conn.php");
11+
?>
12+
</head>
13+
<body>
14+
<!-- login form -->
15+
<div class="container mx-auto">
16+
<?php
17+
if(isset($_POST['loginBtn'])){
18+
$username = $_POST['username'];
19+
$password = $_POST['password'];
20+
if(!$conn){
21+
die("Connection Failed ".mysqli_connect_errno());
22+
}else{
23+
$query = "SELECT * from user WHERE username = '$username' && password = '$password'";
24+
if(mysqli_query($conn,$query)){
25+
$results = mysqli_query($conn,$query);
26+
$array = mysqli_fetch_array($results);
27+
if(count($array) == 0);{ ?>
28+
<div class="alert alert-dismissible alert-danger">
29+
<button type="button" class="close" data-dismiss="alert">&times;</button>
30+
<strong>Username or password incorrect</strong>
31+
</div>
32+
<?php
33+
}
34+
}else{
35+
die(mysqli_error());
36+
}
37+
}
38+
}
39+
?>
40+
41+
<div class="card">
42+
<div class="card-header text-center"><span class="h2">Login</span></div>
43+
<div class="card-body text-center">
44+
<div class="form-group text-center">
45+
<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post">
46+
<input type="text" name="username" id="username" class="form-control" placeholder="Username" value=""><br>
47+
<input type="password" name="password" id="password" class="form-control" placeholder="Password"><br>
48+
<input type="submit" value="Login" name="loginBtn" id="loginBtn" class="btn btn-dark btn-lg">
49+
</div>
50+
</div>
51+
<div class="card-footer text-center">
52+
<div class="h5">Not a member yet ? <a href="register.php" class="btn btn-sm btn-primary">Register Here</a></div>
53+
</div>
54+
</div>
55+
</div>
56+
</body>
57+
</html>

‎login.jpg

2.82 MB
Loading

‎register.css

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.container{
2+
opacity: 0.8;
3+
position: absolute;
4+
top : 50%;
5+
transform: translate(-50%,-50%);
6+
left : 50%;
7+
}
8+
9+
body{
10+
background: url("register.jpg");
11+
background-size: cover;
12+
}

‎register.jpg

5.59 MB
Loading

‎register.php

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<link rel="stylesheet" href="register.css">
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
8+
<title>Register</title>
9+
<?php require("bootstrap.php");
10+
require("conn.php");
11+
?>
12+
</head>
13+
<body>
14+
15+
<div class="container mx-auto">
16+
<?php
17+
if(isset($_POST['registerBtn'])){
18+
$name = $_POST['name'];
19+
$email = $_POST['email'];
20+
$username = $_POST['username'];
21+
$password = $_POST['password'];
22+
if(!$conn){
23+
die("Connection Failed ".mysqli_connect_errno());
24+
}else{
25+
if(!($name="") || !($username="") || !($email="") || !($password=""))
26+
$query = "INSERT INTO user(name,email,username,password) VALUES('$name','$email','$username','$password')";
27+
if(mysqli_query($conn,$query)){
28+
?>
29+
<div class="alert alert-dismissible alert-success">
30+
<button type="button" class="close" data-dismiss="alert">&times;</button>
31+
<strong>Successfully Registered</strong>
32+
</div>
33+
<?php
34+
}else{
35+
die(mysqli_error($conn));
36+
}
37+
}
38+
}
39+
?>
40+
<!-- REGISTER form -->
41+
<div class="card">
42+
<div class="card-header text-center"><span class="h2">Register</span></div>
43+
<div class="card-body text-center">
44+
<div class="form-group text-center">
45+
<form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF'])?>" method="post">
46+
<input type="text" name="name" id="name" class="form-control" placeholder="Full Name" required><br>
47+
<input type="text" name="email" id="email" class="form-control" placeholder="Email Id" value="" required><br>
48+
<input type="text" name="username" id="username" class="form-control" placeholder="Username" value="" required><br>
49+
<input type="password" name="password" id="password" class="form-control" placeholder="Password" required><br>
50+
<input type="submit" value="Register" name="registerBtn" id="registerBtn" class="btn btn-dark btn-lg">
51+
</div>
52+
</div>
53+
<div class="card-footer text-center">
54+
<div class="h5">Already a member ? <a href="index.php" class="btn btn-sm btn-primary">Login Here</a></div>
55+
</div>
56+
</div>
57+
</div>
58+
</body>
59+
</html>

0 commit comments

Comments
 (0)
Please sign in to comment.