-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustomerPasswordChangeProcess.php
39 lines (36 loc) · 1.53 KB
/
customerPasswordChangeProcess.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
<?php
require "connection.php";
$code = $_POST["code"];
$password1 = $_POST["password1"];
$password2 = $_POST["password2"];
$email = $_POST["email"];
if(empty($code)){
echo("PLease enter verification code");
}else if(strlen($code) != 6){
echo("Verification code must have 6 characters");
}else if(empty($email)){
echo("Please enter your email");
}else if(strlen($email) > 50){
echo("Email address must <50 characters");
}else if(!filter_var($email, FILTER_VALIDATE_EMAIL)){
echo("Invalied email");
}else if(empty($password1)){
echo("PLease enter new password");
}else if(strlen($password1) < 5 | strlen($password1) > 16){
echo("Password must have 8-16 characters");
}else if(empty($password2)){
echo("Please enter confirm password");
}else if($password1 != $password2){
echo("Passwords not matching");
}else{
$verificationResultset = Database::search("SELECT * FROM `customer` WHERE `verification_code`='". $code ."' AND `email`='". $email ."'");
$verificationRownumber = $verificationResultset->num_rows;
if($verificationRownumber > 0){
Database::iud("UPDATE `customer` SET `password`='". $password1 ."' WHERE `email`='". $email ."'");
Database::iud("UPDATE `customer` SET `verification_code`='' WHERE `email`='". $email ."'");
echo("success");
}else{
echo("Invlied verification code and Email");
}
}
?>