forked from ahampriyanshu/vaachaal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
passbackend.php
36 lines (28 loc) · 903 Bytes
/
passbackend.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
<?php session_start(); ?>
<?php
if(!isset($_SESSION['loggedin'])){
header('location:index.php');}
?>
<?php
include("essentials/database.php");
$username = $_SESSION['loggedin'];
$password = $_POST['pass'];
$newpassword = $_POST['npass'];
$sql = "INSERT INTO userbase (username,password)
VALUES ('$username','$password')";
$q = "select * from userbase where username = '$username' && password = '$password' ";
$result = mysqli_query($con,$q);
$num = mysqli_num_rows($result);
if ($num == 1) {
$sql=mysqli_query($con,"UPDATE userbase SET password = '$newpassword' WHERE username='$username'");
echo "<script>
alert('Password successfully changed');
document.location='signout.php';
</script>";
} else {
echo "<script>
alert('Incorrect details! Please try again');
document.location='changepassword.php';
</script>";
}
?>