-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcheck_forget.php
77 lines (65 loc) · 1.87 KB
/
check_forget.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
<?php
include"db_conn.php";
if(isset($_POST['mob']) && isset($_POST['pas']) && isset($_POST['cpas'])){
function validate($data){
$data=trim($data);
$data=stripslashes($data);
$data=htmlspecialchars($data);
return $data;
}
$mob=validate($_POST['mob']);
$pas=validate($_POST['pas']);
$cpas=validate($_POST['cpas']);
if(empty($mob)){
header("Location: forget.php?error=Mobile Number is required");
exit();
}else if(empty($pas)){
header("Location: forget.php?error=New Password is required");
exit();
}else if(empty($cpas)){
header("Location: forget.php?error=Confirm Password is required");
exit();
}else if($pas <> $cpas){
header("Location: forget.php?error=Password and Confirm Password Must Same");
exit();
}else{
$m=(int)$mob;
$s="select * from cust where mobno=$m";
$result=pg_query($conn,$s);
$r=pg_fetch_array($result,$row=null);
if($r == NULL){
header("Location: forget.php?error=Mobile Number is not exist");
exit();
}
if(strlen($pas) < 6){
header("Location: forget.php?error=New Password is too small");
exit();
}
if(strlen($pas) > 16){
header("Location: forget.php?error=New Password is too large");
exit();
}
// $sql="insert into cust(mobno,cname,password) values($m,'$name','$pas')";
$sql="update cust set password='$pas' where mobno='$m' ";
if(pg_query($conn,$sql)){
echo"<script>
alert('Password Changed');
window.location.href='login.php';
</script>";
}else{
header("Location: forget.php?error=Invalid ID");
exit();
}
// $r=pg_fetch_array(boolval($result),$row=null);
// if($r==FALSE){
// header("Location: registration.php?error=Invalid ID Number or Password");
// exit();
// }else{
// echo "Hello";
// }
}
}else{
header("Location: registration.php?error");
exit();
}
?>