Completed
Push — master ( d23ee3...b76728 )
by Ankit
02:15
created
source/Login.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
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
 {
@@ -24,20 +24,20 @@  discard block
 block discarded – undo
24 24
 		$login = trim($login);
25 25
 		$password = trim($password);
26 26
 
27
-		if(empty($login))
27
+		if (empty($login))
28 28
 		{
29 29
 			$this->key = 1;
30 30
 			$this->error = array_merge($this->error, ["login" => " *Enter the login field"]);
31 31
 		}
32 32
 		elseif (preg_match("/^[@]{1}$/", $login))
33 33
 		{
34
-			if(filter_var($login, FILTER_VALIDATE_EMAIL) == false)
34
+			if (filter_var($login, FILTER_VALIDATE_EMAIL) == false)
35 35
 			{
36 36
 			$this->key = 1;
37 37
 			$this->error = array_merge($this->error, ["login" => " *Enter correct Email address"]);
38 38
 			}
39 39
 		}
40
-		if(empty($password)) {
40
+		if (empty($password)) {
41 41
 			$this->key = 1;
42 42
 			$this->error = array_merge($this->error, ["password" => " *Enter the password"]);
43 43
 		}
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 			$pass = md5($password);
47 47
 		}
48 48
 
49
-		if($this->key == 0)
49
+		if ($this->key == 0)
50 50
 		{
51 51
 			$query = "SELECT * FROM login WHERE email = '$login' or username = '$login'";
52 52
 			if ($result = $this->connect->query($query))
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 					$row = $result->fetch_assoc();
57 57
 					$loginID = $row['login_id'];
58 58
 					$query = "SELECT id FROM register WHERE id = '$loginID' and password = '$pass'";
59
-					if($result = $this->connect->query($query))
59
+					if ($result = $this->connect->query($query))
60 60
 					{
61 61
 						if ($result->num_rows > 0)
62 62
 						{
Please login to merge, or discard this patch.
source/Register.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
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
 {
@@ -32,45 +32,45 @@  discard block
 block discarded – undo
32 32
 			$this->onError(["name" => " *Enter the name"]);
33 33
 		}
34 34
 
35
-		if(empty($email)) {
35
+		if (empty($email)) {
36 36
 			$this->onError(["email" => " *Enter the email address"]);
37 37
 		}
38
-		elseif(filter_var($email, FILTER_VALIDATE_EMAIL) == false) {
38
+		elseif (filter_var($email, FILTER_VALIDATE_EMAIL) == false) {
39 39
 			$this->onError(["email" => " *Enter correct Email address"]);
40 40
 		}
41 41
 		else
42 42
 		{
43
-			if($this->obValidate->validateEmailInDb($email) === 1)
43
+			if ($this->obValidate->validateEmailInDb($email) === 1)
44 44
 			{
45 45
 
46 46
 				$this->onError(["email" => " *Email is already registered"]);
47 47
 			}
48 48
 		}
49 49
 
50
-		if(empty($username)) {
50
+		if (empty($username)) {
51 51
 			$this->onError(["username" => " *Enter the username"]);
52 52
 		}
53 53
 		else
54 54
 		{
55
-			if($this->obValidate->validateUsernameInDb($username) === 1)
55
+			if ($this->obValidate->validateUsernameInDb($username) === 1)
56 56
 			{
57 57
 
58 58
 				$this->onError(["username" => " *Username is already registered"]);
59 59
 			}
60 60
 		}
61 61
 
62
-		if(empty($password)) {
62
+		if (empty($password)) {
63 63
 			$this->onError(["password" => " *Enter the password"]);
64 64
 		}
65 65
 
66
-		if(empty($mob)) {
66
+		if (empty($mob)) {
67 67
 			$this->onError(["mob" => " *Enter the Mobile Number"]);
68 68
 		}
69 69
 		elseif (!preg_match("/^[0-9]{10}$/", $mob)) {
70 70
 			$this->onError(["mob" => " *Enter correct Mobile Number"]);
71 71
 		}
72 72
 
73
-		if($this->key == 1)
73
+		if ($this->key == 1)
74 74
 		{
75 75
 			return json_encode($this->error);
76 76
 		}
@@ -79,19 +79,19 @@  discard block
 block discarded – undo
79 79
 			$this->key = 0;
80 80
 			$pass = md5($password);
81 81
 			$query = "INSERT INTO register VALUES(null, '$email', '$username', '$pass')";
82
-			if(!$this->connect->query($query)) {
82
+			if (!$this->connect->query($query)) {
83 83
 				$this->key = 1;
84 84
 				echo "You are not registered || Error in registration2";
85 85
 			}
86 86
 			else
87 87
 			{
88 88
 				$query = "SELECT id FROM register WHERE email = '$email'";
89
-				if($result = $this->connect->query($query)) {
89
+				if ($result = $this->connect->query($query)) {
90 90
 					$row = $result->fetch_assoc();
91 91
 					$UserId = $row['id'];
92 92
 
93 93
 					$query = "INSERT INTO login VALUES('$UserId', '$name', '$email', '$username', '$mob')";
94
-					if(!$this->connect->query($query)) {
94
+					if (!$this->connect->query($query)) {
95 95
 						$this->key = 1;
96 96
 						echo "You are not registered || Error in registration1";
97 97
 					}
Please login to merge, or discard this patch.