-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathogrenci_sifre_degistir.php
78 lines (65 loc) · 2.67 KB
/
ogrenci_sifre_degistir.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
<?php
include "database.php";
session_start();
if (!isset($_SESSION["ID"])) {
echo "<script>window.open('ogrenci_anasayfa.php?mes=Hata...','_self');</script>";
}
$sql = "SELECT * FROM student WHERE ID={$_SESSION["ID"]}";
$res = $db->query($sql);
if ($res->num_rows > 0) {
$row = $res->fetch_assoc();
}
?>
<!DOCTYPE html>
<html>
<head>
<title>E-OKUL</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<?php include "ust_kisayol.php"; ?>
<div id="section">
<?php include "yan_kisayol.php"; ?><br>
<h3 class="text">Hoşgeldiniz <?php echo $_SESSION["NAME"]; ?></h3><br><hr><br>
<div class="content">
<h3>Şifre Değiştir</h3><br>
<div class="lbox1">
<?php
if (isset($_POST["submit"])) {
$opass = $_POST["opass"];
$npass = $_POST["npass"];
$cpass = $_POST["cpass"];
$sql = "SELECT SPASS FROM student WHERE ID={$_SESSION["ID"]}";
$result = $db->query($sql);
if ($result->num_rows > 0) {
$row = $result->fetch_assoc();
$hash = $row["SPASS"];
if (password_verify($opass, $hash)) {
if ($npass === $cpass) {
$hashedPassword = password_hash($npass, PASSWORD_ARGON2ID);
$sql = "UPDATE student SET SPASS='{$hashedPassword}' WHERE ID={$_SESSION["ID"]}";
$db->query($sql);
echo "<div class='success'>Şifre Değiştirildi</div>";
} else {
echo "<div class='error'>Şifreler Uyuşmuyor</div>";
}
} else {
echo "<div class='error'>Geçersiz Eski Şifre</div>";
}
}
}
?>
<form method="post" action="<?php echo $_SERVER["PHP_SELF"]; ?>">
<label>Eski Şifre</label><br>
<input type="password" class="input3" name="opass"><br><br>
<label>Yeni Şifre</label><br>
<input type="password" class="input3" name="npass"><br><br>
<label>Şifre Tekrar</label><br>
<input type="password" class="input3" name="cpass"><br><br>
<button type="submit" class="btn" style="float:left" name="submit">Onayla</button>
</form>
</div>
</div>
</div>
</body>
</html>