-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsignup-contr.classes.php
More file actions
122 lines (100 loc) · 2.46 KB
/
Copy pathsignup-contr.classes.php
File metadata and controls
122 lines (100 loc) · 2.46 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<?php
class SignupContr extends Signup{
private $uid;
private $pwd;
private $pwdRepeat;
private $email;
public function __construct($uid, $pwd, $pwdRepeat, $email){
$this->uid=$uid;
$this->pwd=$pwd;
$this->pwdRepeat=$pwdRepeat;
$this->email=$email;
}
public function signupUser(){
if($this->emptyInput()==false){
//echo "Empty Input!";
header("location:../index.php?error=emptyinput");
exit();
}
if($this->invalidUid()==false){
//echo "Invalid Username!";
header("location:../index.php?error=username");
exit();
}
if($this->invalidEmail()==false){
//echo "Invalid Email!";
header("location:../index.php?error=email");
exit();
}
if($this->pwdMatch()==false){
//echo "Password is not Matched!";
header("location:../index.php?error=password");
exit();
}
if($this->uidTakenCheck()==false){
//echo "User or Email taken!";
header("location:../index.php?error=uidoremailtaken");
exit();
}
$this->setUser($this->uid, $this->pwd, $this->email);
}
private function emptyInput(){
$result=true;
if(empty($this->uid) || empty($this->pwd) || empty($this->pwdRepeat) || empty($this->email)) {
$result=false;
}
else{
$result=true;
}
return $result;
}
//Invalid User name
private function invalidUid(){
$result=true;
if(!preg_match("/^[a-zA-Z0-9]*$/", $this->uid))
{
$result=false;
}
else{
$result=true;
}
return $result;
}
//Invalid Email
private function invalidEmail(){
$result=true;
if(!filter_var($this->email, FILTER_VALIDATE_EMAIL))
{
$result=false;
}
else{
$result=true;
}
return $result;
}
//Password Matched
private function pwdMatch(){
$result=true;
if($this->pwd !==$this->pwdRepeat)
{
$result=false;
}
else{
$result=true;
}
return $result;
}
//User is Checked
private function uidTakenCheck(){
$result=true;
if(!$this->checkUser($this->uid, $this->email))
{
$result=false;
}
else{
$result=true;
}
return $result;
}
}
?>