-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchange_password.php
118 lines (102 loc) · 3.6 KB
/
change_password.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
<!DOCTYPE html>
<?php
session_start();
include("header.php");
if(!isset($_SESSION['user_email'])){
header("location: index.php");
}
?>
<html>
<head>
<title>Forgetten Password</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="style/home_style2.css">
</head>
<style>
body{
overflow-x: hidden;
}
.main-content{
width: 50%;
height: 40%;
margin: 10px auto;
background-color: #fff;
border: 2px solid #e6e6e6;
padding: 40px 50px;
}
.header{
border: 0px solid #000;
margin-bottom: 5px;
}
.well{
background-color: #187FAB;
}
#signup{
width: 60%;
border-radius : 30px;
}
</style>
<body>
<div class="row">
<div class = "col-sm-12">
<div class = "well">
<center>
<h1 style="color: white;"><strong>Coding Cafe</strong></h1>
</center>
</div>
</div>
</div>
<div class = "row">
<div class = "col-sm-12">
<div class = "main-content">
<div class = "header">
<h3 style="text-align : center"><strong>Change Your Password.</strong></h3><hr>
</div>
<div class="l_pass">
<form action="" method="POST">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
<input type="password" name="pass" id="password" class="form-control" placeholder="New Password." required>
</div><br>
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
<input type="password" name="pass1" id="msg" class = "form-control" placeholder="Re-Enter Password" required>
</div><br>
<center><button id="signup" class="btn btn-info btn-lg" name="change">Change Password</button></center>
</form>
</div>
</div>
</div>
</div>
</body>
</html>
<?php
if (isset($_POST['change'])) {
$user = $_SESSION['user_email'];
$get_user = "select * from users where user_email='$user'";
$run_user = mysqli_query($con,$get_user);
$row = mysqli_fetch_array($run_user);
$user_id = $row['user_id'];
$pass = htmlentities(mysqli_real_escape_string($con, $_POST['pass']));
$pass1 = htmlentities(mysqli_real_escape_string($con,$_POST['pass1']));
if($pass == $pass1){
if(strlen($pass) >= 6 && strlen($pass) <= 60){
$update = "update users set user_pass = '$pass' where user_id = '$user_id'";
$run = mysqli_query($con, $update);
echo "<script>alert('Your password has be successfully updated few moments ago.')</script>";
echo "<script>window.open('signin.php', '_self')</script>";
}
else{
echo "<script>alert('Your password should be greater than 6 words');</script>";
}
}
else{
echo "<script>alert('Your passwords did not match ');</script>";
echo "<script>windows.open('change_password.php', '_self')</script>";
}
}
?>