-
Notifications
You must be signed in to change notification settings - Fork 0
/
officerChangePasswordProcess.php
32 lines (29 loc) · 1.13 KB
/
officerChangePasswordProcess.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
<?php
require "connection.php";
$username = $_POST["username"];
$verificationCode = $_POST["verificationCode"];
$newPassword = $_POST["newPassword"];
$retypePassword = $_POST["retypePassword"];
if(empty($username)){
echo("Missing Username");
}else if(empty($newPassword)){
echo("Please enter a New Password");
}else if(strlen($newPassword) < 6 || strlen($newPassword) > 20){
echo("Invalied Password");
}else if(empty($retypePassword)){
echo("Please re-type a New Password");
}else if($newPassword != $retypePassword){
echo("Password does not matched");
}else if(empty($verificationCode)){
echo("Please enter Verification Code");
}else{
$officerResultset = Database::search("SELECT * FROM `teacher` WHERE `username`='".$username."' AND `verification_code`='".$verificationCode."'");
$officerRownumber = $officerResultset->num_rows;
if($officerRownumber == 1){
Database::insertUpdateDelete("UPDATE `teacher` SET `password`='".$newPassword."' WHERE `username`='".$username."'");
echo("success");
}else{
echo("Invalid Username or Verification Code");
}
}
?>