forked from subrat-sahu/Navita
-
Notifications
You must be signed in to change notification settings - Fork 0
/
signup.php
193 lines (179 loc) · 7.59 KB
/
signup.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
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.min.css">
<script type="text/javascript" src="bootstrap/js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="bootstrap/js/bootstrap.min.js"></script>
<script src="https://use.fontawesome.com/cc6df5477b.js"></script>
<title>Navita | Signup</title>
<link rel="stylesheet" type="text/css" href="style.css">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<!-- Responsive Navigation Bar -->
<nav class="navbar navbar-inverse navbar-fixed-top ">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.php">Navita</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
<li><a href="index.php">Home</a></li>
<li><a href="#">List of PG's</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="#" id="login"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
<li><a href="signup.php"><span class="glyphicon glyphicon-user"></span> Sign Up</a></li>
</ul>
</div>
</div>
</nav>
<!-- Login call -->
<div id="logindiv" class="modal">
<form class="modal-content animate" action="" method="post">
<div class="imgcontainer">
<span class="close" title="Close">×</span>
<img src="img/avatar1.jpg" alt="Avatar" class="avatar">
</div>
<div class="container1">
<label><b>Email</b></label>
<input type="email" placeholder="Enter Email" name="email" required>
<label><b>Password</b></label>
<input type="password" placeholder="Enter Password" name="password" required>
<button type="submit">Login</button>
<input type="checkbox" checked="checked"> Remember me
</div>
<div class="container1" id="loginbottom">
<button type="button" class="cancelbtn">Cancel</button>
<span class="password">Forgot <a href="#">password?</a></span>
</div>
</form>
<?php
//php login validation
$servername = "localhost";
$username = "root";
$password = "burnitdown";
$dbname = "navita";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error)
die("Connection failed: ". $conn->connect_error);
if (isset($_POST['login']))
{
$email = mysqli_real_escape_string($conn,$_POST['email']);
$password = mysqli_real_escape_string($conn,$_POST['password']);
$hashed_password = hash("sha256",$password);
$sql = "SELECT email,password FROM users WHERE email='$email' AND password='$hashed_password' ";
$result = mysqli_query($conn,$sql);
if (mysqli_num_rows($result))
{
header("Location:dashboard.php");
}
else
{
echo "Invalid credentials";
}
}
?>
</div>
<!-- Final Design -->
<div class="wrapper">
<div class="row1">
<div class="col-7" id="leftimage"> <!-- Only in Desktop -->
<br><br><br><br><br>
<h3>NEED AN ACCOUNT?</h3><br>
<h1>CREATE ACCOUNT</h1>
</div>
<div class="col-1"></div>
<div class="col-4" id="rightform">
<!-- Heading to join Navita -->
<div id="head">
<h4>CREATE ACCOUNT</h4> <!-- Only in Mobile -->
</div>
<form action="" method="post">
<input type="text" placeholder="First Name" required class="form-control" name="fname"><br>
<input type="text" placeholder="Last Name" required class="form-control" name="lname"><br>
<label class="radio-inline"><input type="radio" name="gender" value="male" required>Male</label>
<label class="radio-inline"><input type="radio" name="gender" value="female">Female</label>
<label class="radio-inline"><input type="radio" name="gender" value="other">Other</label><br><br>
<input type="email" placeholder="Email" required class="form-control" name="email"><br>
<input type="password" placeholder="Password" required class="form-control" name=password><br>
<input type="password" placeholder="Confirm Password" required class="form-control" name="confirm_password"><br>
<input type="text" placeholder="Address" required class="form-control" name="address"><br>
<input type="number" placeholder="Contact Number" required class="form-control" name="contact_number"><br>
<input type="submit" value="Sign Up" name="signup" class="btn btn-block btn-danger">
</form>
<?php
$login = 0;
if (isset($_POST['signup']))
{
$first_name = mysqli_real_escape_string($conn,$_POST['fname']);
$last_name = mysqli_real_escape_string($conn,$_POST['lname']);
$gender = mysqli_real_escape_string($conn,$_POST['gender']);
$email = mysqli_real_escape_string($conn,$_POST['email']);
$password = mysqli_real_escape_string($conn,$_POST['password']);
$confirm_password = mysqli_real_escape_string($conn,$_POST['confirm_password']);
$address = mysqli_real_escape_string($conn,$_POST['address']);
$contact_number = mysqli_real_escape_string($conn,$_POST['contact_number']);
if ($password === $confirm_password)
{
$hashed_password = hash("sha256",$password);
$sql = "INSERT INTO users VALUES ('$first_name','$last_name','$gender','$email','$hashed_password','$address','$contact_number') ";
$login = 1;
if ($conn->query($sql) === FALSE)
{
echo "<br><h4 style='color:red'>Email already registered</h4><br>";
$login = 0;
}
}
else
{
echo "<br><h4 style='color:red'>Password not matched</h4><br>";
}
if ($login === 1)
{
header("Location:dashboard.php");
}
}
$conn->close();
?>
</div>
</div>
</div>
<!-- Footer -->
<footer id="footer" >
<div class="container-made">
<div>
<center>
<a href="#">About us</a> |
<a href="#">Contact us</a> |
<a href="#">Careers</a> |
<a href="#">Privacy Policy</a> |
<a href="#">Blog</a> |
<a href="#">Terms and Conditions</a>
</center>
</div>
<div id="follow">
<center>
<h3>Follow us on</h3>
<a href="#"><i class="fa fa-facebook" style="font-size:40px; color:white"></i></a>
<a href="#"><i class="fa fa-twitter" style="font-size:40px; color:white"></i></a>
<a href="#"><i class="fa fa-linkedin" style="font-size:40px; color:white"></i></a>
<a href="#"><i class="fa fa-google-plus" style="font-size:40px; color:white"></i></a>
<a href="#"><i class="fa fa-youtube" style="font-size:40px; color:white"></i></a>
</div>
</center>
</div>
<center>
<p>Copyright ©Navita. All Rights Reserved | Contact Us: +91 7577045235</p>
</center>
</div>
</footer>
<script type="text/javascript" src="script.js" ></script>
</body>
</html>