@@ -55,7 +55,7 @@ |
||
55 | 55 | * |
56 | 56 | * @param array $data Contains the User Credentials |
57 | 57 | * |
58 | - * @return json |
|
58 | + * @return string |
|
59 | 59 | */ |
60 | 60 | public function authLogin($data) |
61 | 61 | { |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | */ |
26 | 26 | class Login |
27 | 27 | { |
28 | - /* |
|
28 | + /* |
|
29 | 29 | |-------------------------------------------------------------------------- |
30 | 30 | | Login Class |
31 | 31 | |-------------------------------------------------------------------------- |
@@ -34,131 +34,131 @@ discard block |
||
34 | 34 | | |
35 | 35 | */ |
36 | 36 | |
37 | - protected $flag; |
|
38 | - protected $error; |
|
39 | - protected $connect; |
|
37 | + protected $flag; |
|
38 | + protected $error; |
|
39 | + protected $connect; |
|
40 | 40 | |
41 | - /** |
|
42 | - * Create a new controller instance. |
|
43 | - * |
|
44 | - * @return void |
|
45 | - */ |
|
46 | - public function __construct() |
|
47 | - { |
|
48 | - $this->flag = 0; |
|
49 | - $this->connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); |
|
50 | - $this->error = array(); |
|
51 | - } |
|
41 | + /** |
|
42 | + * Create a new controller instance. |
|
43 | + * |
|
44 | + * @return void |
|
45 | + */ |
|
46 | + public function __construct() |
|
47 | + { |
|
48 | + $this->flag = 0; |
|
49 | + $this->connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); |
|
50 | + $this->error = array(); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * Credentials check for allowing user to login |
|
55 | - * |
|
56 | - * @param array $data Contains the User Credentials |
|
57 | - * |
|
58 | - * @return json |
|
59 | - */ |
|
60 | - public function authLogin($data) |
|
61 | - { |
|
62 | - $data = $this->emptyValue($data); |
|
53 | + /** |
|
54 | + * Credentials check for allowing user to login |
|
55 | + * |
|
56 | + * @param array $data Contains the User Credentials |
|
57 | + * |
|
58 | + * @return json |
|
59 | + */ |
|
60 | + public function authLogin($data) |
|
61 | + { |
|
62 | + $data = $this->emptyValue($data); |
|
63 | 63 | |
64 | - $login = $data["login"]; |
|
65 | - $password = $data["passLogin"]; |
|
64 | + $login = $data["login"]; |
|
65 | + $password = $data["passLogin"]; |
|
66 | 66 | |
67 | - if (preg_match("/^.+[@]{1}.+$/", $login)) { |
|
68 | - if (filter_var($login, FILTER_VALIDATE_EMAIL) == false) { |
|
69 | - $this->onError("login", " *Enter correct Email address"); |
|
70 | - } |
|
71 | - } |
|
67 | + if (preg_match("/^.+[@]{1}.+$/", $login)) { |
|
68 | + if (filter_var($login, FILTER_VALIDATE_EMAIL) == false) { |
|
69 | + $this->onError("login", " *Enter correct Email address"); |
|
70 | + } |
|
71 | + } |
|
72 | 72 | |
73 | - if ($this->flag == 0) { |
|
74 | - $password = md5($password); |
|
75 | - $query = " |
|
73 | + if ($this->flag == 0) { |
|
74 | + $password = md5($password); |
|
75 | + $query = " |
|
76 | 76 | SELECT * FROM login WHERE email = '$login' or username = '$login' |
77 | 77 | "; |
78 | - if ($result = $this->connect->query($query)) { |
|
79 | - if ($result->num_rows > 0) { |
|
78 | + if ($result = $this->connect->query($query)) { |
|
79 | + if ($result->num_rows > 0) { |
|
80 | 80 | |
81 | - $row = $result->fetch_assoc(); |
|
82 | - $loginID = $row['login_id']; |
|
83 | - $query = " |
|
81 | + $row = $result->fetch_assoc(); |
|
82 | + $loginID = $row['login_id']; |
|
83 | + $query = " |
|
84 | 84 | SELECT id FROM register WHERE |
85 | 85 | id = '$loginID' and |
86 | 86 | password = '$password' |
87 | 87 | "; |
88 | - if ($result = $this->connect->query($query)) { |
|
89 | - if ($result->num_rows > 0) { |
|
90 | - Session::put('start', $loginID); |
|
91 | - return json_encode( |
|
92 | - [ |
|
93 | - "location" => URL . "/account.php" |
|
94 | - ] |
|
95 | - ); |
|
96 | - } |
|
97 | - $this->onError("passLogin", " *Invalid password"); |
|
98 | - return json_encode($this->error); |
|
99 | - } |
|
100 | - return json_encode( |
|
101 | - [ |
|
102 | - "Error" => "You are not registered, " . $this->connect->error |
|
103 | - ] |
|
104 | - ); |
|
105 | - } |
|
106 | - $this->onError("login", " *Invalid username or email"); |
|
107 | - return json_encode($this->error); |
|
108 | - } |
|
109 | - return json_encode( |
|
110 | - [ |
|
111 | - "Error" => "You are not registered, " . $this->connect->error |
|
112 | - ] |
|
113 | - ); |
|
114 | - } else { |
|
115 | - return json_encode($this->error); |
|
116 | - } |
|
117 | - } |
|
88 | + if ($result = $this->connect->query($query)) { |
|
89 | + if ($result->num_rows > 0) { |
|
90 | + Session::put('start', $loginID); |
|
91 | + return json_encode( |
|
92 | + [ |
|
93 | + "location" => URL . "/account.php" |
|
94 | + ] |
|
95 | + ); |
|
96 | + } |
|
97 | + $this->onError("passLogin", " *Invalid password"); |
|
98 | + return json_encode($this->error); |
|
99 | + } |
|
100 | + return json_encode( |
|
101 | + [ |
|
102 | + "Error" => "You are not registered, " . $this->connect->error |
|
103 | + ] |
|
104 | + ); |
|
105 | + } |
|
106 | + $this->onError("login", " *Invalid username or email"); |
|
107 | + return json_encode($this->error); |
|
108 | + } |
|
109 | + return json_encode( |
|
110 | + [ |
|
111 | + "Error" => "You are not registered, " . $this->connect->error |
|
112 | + ] |
|
113 | + ); |
|
114 | + } else { |
|
115 | + return json_encode($this->error); |
|
116 | + } |
|
117 | + } |
|
118 | 118 | |
119 | - /** |
|
120 | - * For generating Error array by key value pair |
|
121 | - * |
|
122 | - * @param string $key Contains key |
|
123 | - * @param string $value Contains the Value for the key |
|
124 | - * |
|
125 | - * @return void |
|
126 | - */ |
|
127 | - public function onError($key, $value) |
|
128 | - { |
|
129 | - $this->flag = 1; |
|
130 | - $this->error = array_merge( |
|
131 | - $this->error, |
|
132 | - [ |
|
133 | - [ |
|
134 | - "key" => $key, |
|
135 | - "value" => $value |
|
136 | - ] |
|
137 | - ] |
|
138 | - ); |
|
139 | - } |
|
119 | + /** |
|
120 | + * For generating Error array by key value pair |
|
121 | + * |
|
122 | + * @param string $key Contains key |
|
123 | + * @param string $value Contains the Value for the key |
|
124 | + * |
|
125 | + * @return void |
|
126 | + */ |
|
127 | + public function onError($key, $value) |
|
128 | + { |
|
129 | + $this->flag = 1; |
|
130 | + $this->error = array_merge( |
|
131 | + $this->error, |
|
132 | + [ |
|
133 | + [ |
|
134 | + "key" => $key, |
|
135 | + "value" => $value |
|
136 | + ] |
|
137 | + ] |
|
138 | + ); |
|
139 | + } |
|
140 | 140 | |
141 | - /** |
|
142 | - * For checking whether the credentials are empty or not |
|
143 | - * |
|
144 | - * @param array $data Contains the Credentials |
|
145 | - * |
|
146 | - * @return array |
|
147 | - */ |
|
148 | - public function emptyValue($data) |
|
149 | - { |
|
150 | - $errorCode = array( |
|
151 | - "login" => " *Enter the login field", |
|
152 | - "passLogin" => " *Enter the password" |
|
153 | - ); |
|
141 | + /** |
|
142 | + * For checking whether the credentials are empty or not |
|
143 | + * |
|
144 | + * @param array $data Contains the Credentials |
|
145 | + * |
|
146 | + * @return array |
|
147 | + */ |
|
148 | + public function emptyValue($data) |
|
149 | + { |
|
150 | + $errorCode = array( |
|
151 | + "login" => " *Enter the login field", |
|
152 | + "passLogin" => " *Enter the password" |
|
153 | + ); |
|
154 | 154 | |
155 | - foreach ($data as $key => $value) { |
|
156 | - $data[$key] = trim($data[$key]); |
|
157 | - $value = trim($value); |
|
158 | - if (empty($value)) { |
|
159 | - $this->onError($key, $errorCode[$key]); |
|
160 | - } |
|
161 | - } |
|
162 | - return $data; |
|
163 | - } |
|
155 | + foreach ($data as $key => $value) { |
|
156 | + $data[$key] = trim($data[$key]); |
|
157 | + $value = trim($value); |
|
158 | + if (empty($value)) { |
|
159 | + $this->onError($key, $errorCode[$key]); |
|
160 | + } |
|
161 | + } |
|
162 | + return $data; |
|
163 | + } |
|
164 | 164 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | namespace AnkitJain\RegistrationModule; |
14 | 14 | use AnkitJain\RegistrationModule\Session; |
15 | -require_once dirname(__DIR__) . '/config/database.php'; |
|
15 | +require_once dirname(__DIR__).'/config/database.php'; |
|
16 | 16 | |
17 | 17 | /** |
18 | 18 | * For Login the User |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | Session::put('start', $loginID); |
91 | 91 | return json_encode( |
92 | 92 | [ |
93 | - "location" => URL . "/account.php" |
|
93 | + "location" => URL."/account.php" |
|
94 | 94 | ] |
95 | 95 | ); |
96 | 96 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | } |
100 | 100 | return json_encode( |
101 | 101 | [ |
102 | - "Error" => "You are not registered, " . $this->connect->error |
|
102 | + "Error" => "You are not registered, ".$this->connect->error |
|
103 | 103 | ] |
104 | 104 | ); |
105 | 105 | } |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | } |
109 | 109 | return json_encode( |
110 | 110 | [ |
111 | - "Error" => "You are not registered, " . $this->connect->error |
|
111 | + "Error" => "You are not registered, ".$this->connect->error |
|
112 | 112 | ] |
113 | 113 | ); |
114 | 114 | } else { |
@@ -60,7 +60,7 @@ |
||
60 | 60 | * |
61 | 61 | * @param array $data Contains the User Credentials |
62 | 62 | * |
63 | - * @return json |
|
63 | + * @return string|null |
|
64 | 64 | */ |
65 | 65 | public function authRegister($data) |
66 | 66 | { |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | |
29 | 29 | class Register |
30 | 30 | { |
31 | - /* |
|
31 | + /* |
|
32 | 32 | |-------------------------------------------------------------------------- |
33 | 33 | | Register Class |
34 | 34 | |-------------------------------------------------------------------------- |
@@ -37,142 +37,142 @@ discard block |
||
37 | 37 | | |
38 | 38 | */ |
39 | 39 | |
40 | - protected $error; |
|
41 | - protected $flag; |
|
42 | - protected $obValidate; |
|
43 | - protected $connect; |
|
44 | - |
|
45 | - /** |
|
46 | - * Create a new controller instance. |
|
47 | - * |
|
48 | - * @return void |
|
49 | - */ |
|
50 | - public function __construct() |
|
51 | - { |
|
52 | - $this->error = array(); |
|
53 | - $this->flag = 0; |
|
54 | - $this->connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); |
|
55 | - $this->obValidate = new Validate(); |
|
56 | - } |
|
57 | - |
|
58 | - /** |
|
59 | - * Credentials check for allowing new user to Register |
|
60 | - * |
|
61 | - * @param array $data Contains the User Credentials |
|
62 | - * |
|
63 | - * @return json |
|
64 | - */ |
|
65 | - public function authRegister($data) |
|
66 | - { |
|
67 | - $data = $this->emptyValue($data); |
|
68 | - $name = $data["name"]; |
|
69 | - $email = $data["email"]; |
|
70 | - $username = $data["username"]; |
|
71 | - $mob = $data["mob"]; |
|
72 | - $password = $data["passRegister"]; |
|
73 | - $userId = ''; |
|
74 | - |
|
75 | - if (filter_var($email, FILTER_VALIDATE_EMAIL) == false) { |
|
76 | - $this->onError("email", " *Enter correct Email address"); |
|
77 | - } elseif ($this->obValidate->validateEmailInDb($email) === 1) { |
|
78 | - $this->onError("email", " *Email is already registered"); |
|
79 | - } |
|
80 | - |
|
81 | - if ($this->obValidate->validateUsernameInDb($username) === 1) { |
|
82 | - $this->onError("username", " *Username is already registered"); |
|
83 | - } |
|
84 | - |
|
85 | - if (!preg_match("/^[0-9]{10}$/", $data["mob"])) { |
|
86 | - $this->onError("mob", " *Enter correct Mobile Number"); |
|
87 | - } |
|
88 | - |
|
89 | - if ($this->flag == 1) { |
|
90 | - return json_encode($this->error); |
|
91 | - } |
|
92 | - |
|
93 | - $password = md5($password); |
|
94 | - |
|
95 | - $query = "INSERT INTO register VALUES( |
|
40 | + protected $error; |
|
41 | + protected $flag; |
|
42 | + protected $obValidate; |
|
43 | + protected $connect; |
|
44 | + |
|
45 | + /** |
|
46 | + * Create a new controller instance. |
|
47 | + * |
|
48 | + * @return void |
|
49 | + */ |
|
50 | + public function __construct() |
|
51 | + { |
|
52 | + $this->error = array(); |
|
53 | + $this->flag = 0; |
|
54 | + $this->connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); |
|
55 | + $this->obValidate = new Validate(); |
|
56 | + } |
|
57 | + |
|
58 | + /** |
|
59 | + * Credentials check for allowing new user to Register |
|
60 | + * |
|
61 | + * @param array $data Contains the User Credentials |
|
62 | + * |
|
63 | + * @return json |
|
64 | + */ |
|
65 | + public function authRegister($data) |
|
66 | + { |
|
67 | + $data = $this->emptyValue($data); |
|
68 | + $name = $data["name"]; |
|
69 | + $email = $data["email"]; |
|
70 | + $username = $data["username"]; |
|
71 | + $mob = $data["mob"]; |
|
72 | + $password = $data["passRegister"]; |
|
73 | + $userId = ''; |
|
74 | + |
|
75 | + if (filter_var($email, FILTER_VALIDATE_EMAIL) == false) { |
|
76 | + $this->onError("email", " *Enter correct Email address"); |
|
77 | + } elseif ($this->obValidate->validateEmailInDb($email) === 1) { |
|
78 | + $this->onError("email", " *Email is already registered"); |
|
79 | + } |
|
80 | + |
|
81 | + if ($this->obValidate->validateUsernameInDb($username) === 1) { |
|
82 | + $this->onError("username", " *Username is already registered"); |
|
83 | + } |
|
84 | + |
|
85 | + if (!preg_match("/^[0-9]{10}$/", $data["mob"])) { |
|
86 | + $this->onError("mob", " *Enter correct Mobile Number"); |
|
87 | + } |
|
88 | + |
|
89 | + if ($this->flag == 1) { |
|
90 | + return json_encode($this->error); |
|
91 | + } |
|
92 | + |
|
93 | + $password = md5($password); |
|
94 | + |
|
95 | + $query = "INSERT INTO register VALUES( |
|
96 | 96 | null, '$email', '$username', '$password' |
97 | 97 | )"; |
98 | - if (!$this->connect->query($query)) { |
|
99 | - return json_encode( |
|
100 | - [ |
|
101 | - "Error" => "You are not registered, " . $this->connect->error |
|
102 | - ] |
|
103 | - ); |
|
104 | - } |
|
105 | - $query = "SELECT id FROM register WHERE email = '$email'"; |
|
106 | - if ($result = $this->connect->query($query)) { |
|
107 | - $row = $result->fetch_assoc(); |
|
108 | - $userId = $row['id']; |
|
109 | - $query = "INSERT INTO login VALUES( |
|
98 | + if (!$this->connect->query($query)) { |
|
99 | + return json_encode( |
|
100 | + [ |
|
101 | + "Error" => "You are not registered, " . $this->connect->error |
|
102 | + ] |
|
103 | + ); |
|
104 | + } |
|
105 | + $query = "SELECT id FROM register WHERE email = '$email'"; |
|
106 | + if ($result = $this->connect->query($query)) { |
|
107 | + $row = $result->fetch_assoc(); |
|
108 | + $userId = $row['id']; |
|
109 | + $query = "INSERT INTO login VALUES( |
|
110 | 110 | '$userId', '$name', '$email', '$username', '$mob' |
111 | 111 | )"; |
112 | 112 | |
113 | - if (!$this->connect->query($query)) { |
|
114 | - return json_encode( |
|
115 | - [ |
|
116 | - "Error" => "You are not registered, " . $this->connect->error |
|
117 | - ] |
|
118 | - ); |
|
119 | - } |
|
120 | - |
|
121 | - Session::put('start', $userId); |
|
122 | - return json_encode( |
|
123 | - [ |
|
124 | - "location" => URL . "/account.php" |
|
125 | - ] |
|
126 | - ); |
|
127 | - } |
|
128 | - } |
|
129 | - |
|
130 | - /** |
|
131 | - * For generating Error array by key value pair |
|
132 | - * |
|
133 | - * @param string $key Contains key |
|
134 | - * @param string $value Contains the Value for the key |
|
135 | - * |
|
136 | - * @return void |
|
137 | - */ |
|
138 | - public function onError($key, $value) |
|
139 | - { |
|
140 | - $this->flag = 1; |
|
141 | - $this->error = array_merge( |
|
142 | - $this->error, |
|
143 | - [ |
|
144 | - [ |
|
145 | - "key" => $key, |
|
146 | - "value" => $value |
|
147 | - ] |
|
148 | - ] |
|
149 | - ); |
|
150 | - } |
|
151 | - |
|
152 | - /** |
|
153 | - * For checking whether the credentials are empty or not |
|
154 | - * |
|
155 | - * @param array $data Contains the Credentials |
|
156 | - * |
|
157 | - * @return array |
|
158 | - */ |
|
159 | - public function emptyValue($data) |
|
160 | - { |
|
161 | - $errorCode = array( |
|
162 | - "name" => " *Enter the name", |
|
163 | - "email" => " *Enter the email address", |
|
164 | - "username" => " *Enter the username", |
|
165 | - "passRegister" => " *Enter the password", |
|
166 | - "mob" => " *Enter the Mobile Number" |
|
167 | - ); |
|
168 | - |
|
169 | - foreach ($data as $key => $value) { |
|
170 | - $data[$key] = trim($data[$key]); |
|
171 | - $value = trim($value); |
|
172 | - if (empty($value)) { |
|
173 | - $this->onError($key, $errorCode[$key]); |
|
174 | - } |
|
175 | - } |
|
176 | - return $data; |
|
177 | - } |
|
113 | + if (!$this->connect->query($query)) { |
|
114 | + return json_encode( |
|
115 | + [ |
|
116 | + "Error" => "You are not registered, " . $this->connect->error |
|
117 | + ] |
|
118 | + ); |
|
119 | + } |
|
120 | + |
|
121 | + Session::put('start', $userId); |
|
122 | + return json_encode( |
|
123 | + [ |
|
124 | + "location" => URL . "/account.php" |
|
125 | + ] |
|
126 | + ); |
|
127 | + } |
|
128 | + } |
|
129 | + |
|
130 | + /** |
|
131 | + * For generating Error array by key value pair |
|
132 | + * |
|
133 | + * @param string $key Contains key |
|
134 | + * @param string $value Contains the Value for the key |
|
135 | + * |
|
136 | + * @return void |
|
137 | + */ |
|
138 | + public function onError($key, $value) |
|
139 | + { |
|
140 | + $this->flag = 1; |
|
141 | + $this->error = array_merge( |
|
142 | + $this->error, |
|
143 | + [ |
|
144 | + [ |
|
145 | + "key" => $key, |
|
146 | + "value" => $value |
|
147 | + ] |
|
148 | + ] |
|
149 | + ); |
|
150 | + } |
|
151 | + |
|
152 | + /** |
|
153 | + * For checking whether the credentials are empty or not |
|
154 | + * |
|
155 | + * @param array $data Contains the Credentials |
|
156 | + * |
|
157 | + * @return array |
|
158 | + */ |
|
159 | + public function emptyValue($data) |
|
160 | + { |
|
161 | + $errorCode = array( |
|
162 | + "name" => " *Enter the name", |
|
163 | + "email" => " *Enter the email address", |
|
164 | + "username" => " *Enter the username", |
|
165 | + "passRegister" => " *Enter the password", |
|
166 | + "mob" => " *Enter the Mobile Number" |
|
167 | + ); |
|
168 | + |
|
169 | + foreach ($data as $key => $value) { |
|
170 | + $data[$key] = trim($data[$key]); |
|
171 | + $value = trim($value); |
|
172 | + if (empty($value)) { |
|
173 | + $this->onError($key, $errorCode[$key]); |
|
174 | + } |
|
175 | + } |
|
176 | + return $data; |
|
177 | + } |
|
178 | 178 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | namespace AnkitJain\RegistrationModule; |
15 | 15 | use AnkitJain\RegistrationModule\Validate; |
16 | 16 | use AnkitJain\RegistrationModule\Session; |
17 | -require_once dirname(__DIR__) . '/config/database.php'; |
|
17 | +require_once dirname(__DIR__).'/config/database.php'; |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * For Register the New User |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | if (!$this->connect->query($query)) { |
99 | 99 | return json_encode( |
100 | 100 | [ |
101 | - "Error" => "You are not registered, " . $this->connect->error |
|
101 | + "Error" => "You are not registered, ".$this->connect->error |
|
102 | 102 | ] |
103 | 103 | ); |
104 | 104 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | if (!$this->connect->query($query)) { |
114 | 114 | return json_encode( |
115 | 115 | [ |
116 | - "Error" => "You are not registered, " . $this->connect->error |
|
116 | + "Error" => "You are not registered, ".$this->connect->error |
|
117 | 117 | ] |
118 | 118 | ); |
119 | 119 | } |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | Session::put('start', $userId); |
122 | 122 | return json_encode( |
123 | 123 | [ |
124 | - "location" => URL . "/account.php" |
|
124 | + "location" => URL."/account.php" |
|
125 | 125 | ] |
126 | 126 | ); |
127 | 127 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | */ |
25 | 25 | class Validate |
26 | 26 | { |
27 | - /* |
|
27 | + /* |
|
28 | 28 | |-------------------------------------------------------------------------- |
29 | 29 | | Validate Class |
30 | 30 | |-------------------------------------------------------------------------- |
@@ -33,51 +33,51 @@ discard block |
||
33 | 33 | | |
34 | 34 | */ |
35 | 35 | |
36 | - protected $connect; |
|
36 | + protected $connect; |
|
37 | 37 | |
38 | - /** |
|
39 | - * Create a new controller instance. |
|
40 | - * |
|
41 | - * @return void |
|
42 | - */ |
|
43 | - public function __construct() |
|
44 | - { |
|
45 | - $this->connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); |
|
46 | - } |
|
38 | + /** |
|
39 | + * Create a new controller instance. |
|
40 | + * |
|
41 | + * @return void |
|
42 | + */ |
|
43 | + public function __construct() |
|
44 | + { |
|
45 | + $this->connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * For checking whether the credentials are empty or not |
|
50 | - * |
|
51 | - * @param string $email Contains the email for checking |
|
52 | - * |
|
53 | - * @return 0 | 1 |
|
54 | - */ |
|
55 | - public function validateEmailInDb($email) |
|
56 | - { |
|
57 | - $query = "SELECT login_id FROM login WHERE email = '$email'"; |
|
58 | - if ($result = $this->connect->query($query)) { |
|
59 | - if ($result->num_rows > 0) { |
|
60 | - return 1; |
|
61 | - } |
|
62 | - return 0; |
|
63 | - } |
|
64 | - } |
|
48 | + /** |
|
49 | + * For checking whether the credentials are empty or not |
|
50 | + * |
|
51 | + * @param string $email Contains the email for checking |
|
52 | + * |
|
53 | + * @return 0 | 1 |
|
54 | + */ |
|
55 | + public function validateEmailInDb($email) |
|
56 | + { |
|
57 | + $query = "SELECT login_id FROM login WHERE email = '$email'"; |
|
58 | + if ($result = $this->connect->query($query)) { |
|
59 | + if ($result->num_rows > 0) { |
|
60 | + return 1; |
|
61 | + } |
|
62 | + return 0; |
|
63 | + } |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * For checking whether the credentials are empty or not |
|
68 | - * |
|
69 | - * @param string $username Contains the username for checking |
|
70 | - * |
|
71 | - * @return 0 | 1 |
|
72 | - */ |
|
73 | - public function validateUsernameInDb($username) |
|
74 | - { |
|
75 | - $query = "SELECT login_id FROM login WHERE username = '$username'"; |
|
76 | - if ($result = $this->connect->query($query)) { |
|
77 | - if ($result->num_rows > 0) { |
|
78 | - return 1; |
|
79 | - } |
|
80 | - return 0; |
|
81 | - } |
|
82 | - } |
|
66 | + /** |
|
67 | + * For checking whether the credentials are empty or not |
|
68 | + * |
|
69 | + * @param string $username Contains the username for checking |
|
70 | + * |
|
71 | + * @return 0 | 1 |
|
72 | + */ |
|
73 | + public function validateUsernameInDb($username) |
|
74 | + { |
|
75 | + $query = "SELECT login_id FROM login WHERE username = '$username'"; |
|
76 | + if ($result = $this->connect->query($query)) { |
|
77 | + if ($result->num_rows > 0) { |
|
78 | + return 1; |
|
79 | + } |
|
80 | + return 0; |
|
81 | + } |
|
82 | + } |
|
83 | 83 | } |
@@ -11,7 +11,7 @@ |
||
11 | 11 | * @link https://github.com/ankitjain28may/registration-module |
12 | 12 | */ |
13 | 13 | namespace AnkitJain\RegistrationModule; |
14 | -require_once dirname(__DIR__) . '/config/database.php'; |
|
14 | +require_once dirname(__DIR__).'/config/database.php'; |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * For validation the Email and Username in DB. |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | |
27 | 27 | class Session |
28 | 28 | { |
29 | - /* |
|
29 | + /* |
|
30 | 30 | |-------------------------------------------------------------------------- |
31 | 31 | | Session Class |
32 | 32 | |-------------------------------------------------------------------------- |
@@ -35,40 +35,40 @@ discard block |
||
35 | 35 | | |
36 | 36 | */ |
37 | 37 | |
38 | - /** |
|
39 | - * For generating Session with the key |
|
40 | - * |
|
41 | - * @param string $key Contains key |
|
42 | - * @param string $value Contains the Value for the key |
|
43 | - * |
|
44 | - * @return void |
|
45 | - */ |
|
46 | - public static function put($key, $value) |
|
47 | - { |
|
48 | - $_SESSION[$key] = $value; |
|
49 | - } |
|
38 | + /** |
|
39 | + * For generating Session with the key |
|
40 | + * |
|
41 | + * @param string $key Contains key |
|
42 | + * @param string $value Contains the Value for the key |
|
43 | + * |
|
44 | + * @return void |
|
45 | + */ |
|
46 | + public static function put($key, $value) |
|
47 | + { |
|
48 | + $_SESSION[$key] = $value; |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * For getting Session value |
|
53 | - * |
|
54 | - * @param string $key Contains key |
|
55 | - * |
|
56 | - * @return string | null |
|
57 | - */ |
|
58 | - public static function get($key) |
|
59 | - { |
|
60 | - return (isset($_SESSION[$key]) ? $_SESSION[$key] : null); |
|
61 | - } |
|
51 | + /** |
|
52 | + * For getting Session value |
|
53 | + * |
|
54 | + * @param string $key Contains key |
|
55 | + * |
|
56 | + * @return string | null |
|
57 | + */ |
|
58 | + public static function get($key) |
|
59 | + { |
|
60 | + return (isset($_SESSION[$key]) ? $_SESSION[$key] : null); |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * For unsetting Session key |
|
65 | - * |
|
66 | - * @param string $key Contains key |
|
67 | - * |
|
68 | - * @return void |
|
69 | - */ |
|
70 | - public static function forget($key) |
|
71 | - { |
|
72 | - unset($_SESSION[$key]); |
|
73 | - } |
|
63 | + /** |
|
64 | + * For unsetting Session key |
|
65 | + * |
|
66 | + * @param string $key Contains key |
|
67 | + * |
|
68 | + * @return void |
|
69 | + */ |
|
70 | + public static function forget($key) |
|
71 | + { |
|
72 | + unset($_SESSION[$key]); |
|
73 | + } |
|
74 | 74 | } |