@@ -71,6 +71,9 @@ |
||
71 | 71 | $this->connect->close(); |
72 | 72 | } |
73 | 73 | |
74 | + /** |
|
75 | + * @param string $value |
|
76 | + */ |
|
74 | 77 | public function onError($key, $value) |
75 | 78 | { |
76 | 79 | $this->flag = 1; |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | namespace AnkitJain\RegistrationModule; |
4 | 4 | use AnkitJain\RegistrationModule\Session; |
5 | -require_once (dirname(__DIR__) . '/config/database.php'); |
|
5 | +require_once (dirname(__DIR__).'/config/database.php'); |
|
6 | 6 | |
7 | 7 | class Login |
8 | 8 | { |
@@ -28,13 +28,13 @@ discard block |
||
28 | 28 | |
29 | 29 | if (preg_match("/^[@]{1}$/", $login)) |
30 | 30 | { |
31 | - if(filter_var($login, FILTER_VALIDATE_EMAIL) == false) |
|
31 | + if (filter_var($login, FILTER_VALIDATE_EMAIL) == false) |
|
32 | 32 | { |
33 | 33 | $this->onError("login", " *Enter correct Email address"); |
34 | 34 | } |
35 | 35 | } |
36 | 36 | |
37 | - if($this->flag == 0) |
|
37 | + if ($this->flag == 0) |
|
38 | 38 | { |
39 | 39 | $password = md5($password); |
40 | 40 | $query = "SELECT * FROM login WHERE email = '$login' or username = '$login'"; |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | $row = $result->fetch_assoc(); |
46 | 46 | $loginID = $row['login_id']; |
47 | 47 | $query = "SELECT id FROM register WHERE id = '$loginID' and password = '$password'"; |
48 | - if($result = $this->connect->query($query)) |
|
48 | + if ($result = $this->connect->query($query)) |
|
49 | 49 | { |
50 | 50 | if ($result->num_rows > 0) |
51 | 51 | { |
@@ -57,12 +57,12 @@ discard block |
||
57 | 57 | $this->onError("passLogin", " *Invalid password"); |
58 | 58 | return json_encode($this->error); |
59 | 59 | } |
60 | - return json_encode(["Error" => "You are not registered, ".$this->connect->error ]); |
|
60 | + return json_encode(["Error" => "You are not registered, ".$this->connect->error]); |
|
61 | 61 | } |
62 | 62 | $this->onError("login", " *Invalid username or email"); |
63 | 63 | return json_encode($this->error); |
64 | 64 | } |
65 | - return json_encode(["Error" => "You are not registered, ".$this->connect->error ]); |
|
65 | + return json_encode(["Error" => "You are not registered, ".$this->connect->error]); |
|
66 | 66 | } |
67 | 67 | else |
68 | 68 | { |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | foreach ($data as $key => $value) { |
88 | 88 | $data[$key] = trim($data[$key]); |
89 | 89 | $value = trim($value); |
90 | - if(empty($value)) |
|
90 | + if (empty($value)) |
|
91 | 91 | { |
92 | 92 | $this->onError($key, $errorCode[$key]); |
93 | 93 | } |
@@ -63,8 +63,7 @@ |
||
63 | 63 | return json_encode($this->error); |
64 | 64 | } |
65 | 65 | return json_encode(["Error" => "You are not registered, ".$this->connect->error ]); |
66 | - } |
|
67 | - else |
|
66 | + } else |
|
68 | 67 | { |
69 | 68 | return json_encode($this->error); |
70 | 69 | } |
@@ -79,6 +79,9 @@ |
||
79 | 79 | } |
80 | 80 | } |
81 | 81 | |
82 | + /** |
|
83 | + * @param string $value |
|
84 | + */ |
|
82 | 85 | public function onError($key, $value) |
83 | 86 | { |
84 | 87 | $this->flag = 1; |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | namespace AnkitJain\RegistrationModule; |
4 | 4 | use AnkitJain\RegistrationModule\Validate; |
5 | 5 | use AnkitJain\RegistrationModule\Session; |
6 | -require_once (dirname(__DIR__) . '/config/database.php'); |
|
6 | +require_once (dirname(__DIR__).'/config/database.php'); |
|
7 | 7 | |
8 | 8 | class Register |
9 | 9 | { |
@@ -30,16 +30,16 @@ discard block |
||
30 | 30 | $password = $data["passRegister"]; |
31 | 31 | $userId = ''; |
32 | 32 | |
33 | - if(filter_var($email, FILTER_VALIDATE_EMAIL) == false) |
|
33 | + if (filter_var($email, FILTER_VALIDATE_EMAIL) == false) |
|
34 | 34 | { |
35 | 35 | $this->onError("email", " *Enter correct Email address"); |
36 | 36 | } |
37 | - else if($this->obValidate->validateEmailInDb($email) === 1) |
|
37 | + else if ($this->obValidate->validateEmailInDb($email) === 1) |
|
38 | 38 | { |
39 | 39 | $this->onError("email", " *Email is already registered"); |
40 | 40 | } |
41 | 41 | |
42 | - if($this->obValidate->validateUsernameInDb($username) === 1) |
|
42 | + if ($this->obValidate->validateUsernameInDb($username) === 1) |
|
43 | 43 | { |
44 | 44 | $this->onError("username", " *Username is already registered"); |
45 | 45 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | $this->onError("mob", " *Enter correct Mobile Number"); |
49 | 49 | } |
50 | 50 | |
51 | - if($this->flag == 1) |
|
51 | + if ($this->flag == 1) |
|
52 | 52 | { |
53 | 53 | return json_encode($this->error); |
54 | 54 | } |
@@ -56,20 +56,20 @@ discard block |
||
56 | 56 | $password = md5($password); |
57 | 57 | |
58 | 58 | $query = "INSERT INTO register VALUES(null, '$email', '$username', '$password')"; |
59 | - if(!$this->connect->query($query)) |
|
59 | + if (!$this->connect->query($query)) |
|
60 | 60 | { |
61 | - return json_encode(["Error" => "You are not registered, ".$this->connect->error ]); |
|
61 | + return json_encode(["Error" => "You are not registered, ".$this->connect->error]); |
|
62 | 62 | } |
63 | 63 | $query = "SELECT id FROM register WHERE email = '$email'"; |
64 | - if($result = $this->connect->query($query)) |
|
64 | + if ($result = $this->connect->query($query)) |
|
65 | 65 | { |
66 | 66 | $row = $result->fetch_assoc(); |
67 | 67 | $userId = $row['id']; |
68 | 68 | $query = "INSERT INTO login VALUES('$userId', '$name', '$email', '$username', '$mob')"; |
69 | 69 | |
70 | - if(!$this->connect->query($query)) |
|
70 | + if (!$this->connect->query($query)) |
|
71 | 71 | { |
72 | - return json_encode(["Error" => "You are not registered, ".$this->connect->error ]); |
|
72 | + return json_encode(["Error" => "You are not registered, ".$this->connect->error]); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | Session::put('start', $userId); |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | foreach ($data as $key => $value) { |
99 | 99 | $data[$key] = trim($data[$key]); |
100 | 100 | $value = trim($value); |
101 | - if(empty($value)) |
|
101 | + if (empty($value)) |
|
102 | 102 | { |
103 | 103 | $this->onError($key, $errorCode[$key]); |
104 | 104 | } |
@@ -33,8 +33,7 @@ |
||
33 | 33 | if(filter_var($email, FILTER_VALIDATE_EMAIL) == false) |
34 | 34 | { |
35 | 35 | $this->onError("email", " *Enter correct Email address"); |
36 | - } |
|
37 | - else if($this->obValidate->validateEmailInDb($email) === 1) |
|
36 | + } else if($this->obValidate->validateEmailInDb($email) === 1) |
|
38 | 37 | { |
39 | 38 | $this->onError("email", " *Email is already registered"); |
40 | 39 | } |
@@ -10,10 +10,10 @@ |
||
10 | 10 | $login = $loginField->login; |
11 | 11 | $password = $loginField->password; |
12 | 12 | $obLogin = new Login(); |
13 | - $data = array( |
|
14 | - 'login' => $login, |
|
15 | - 'passLogin' => $password |
|
16 | - ); |
|
13 | + $data = array( |
|
14 | + 'login' => $login, |
|
15 | + 'passLogin' => $password |
|
16 | + ); |
|
17 | 17 | $result = $obLogin->authLogin($data); |
18 | 18 | if(isset($result)) |
19 | 19 | echo $result; |