Completed
Branch master (d23ee3)
by Ankit
02:15
created
logout.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 namespace AnkitJain\RegistrationModule;
4
-require (dirname(__DIR__) . '/registration-module/vendor/autoload.php');
4
+require (dirname(__DIR__).'/registration-module/vendor/autoload.php');
5 5
 use AnkitJain\RegistrationModule\Session;
6 6
 
7
-if(Session::get('start') != null)
7
+if (Session::get('start') != null)
8 8
 {
9 9
 	Session::forget('start');
10 10
 	header('Location: index.php');
Please login to merge, or discard this patch.
config/database.example.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
   // Define database connection constants
3 3
   define('DB_HOST', 'localhost');
4 4
   define('DB_USER', 'root');
5
-  define('DB_PASSWORD','');
5
+  define('DB_PASSWORD', '');
6 6
   define('DB_NAME', 'account');
7 7
   define('URL', URL());
8 8
 
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
     @$host = $_SERVER['SERVER_NAME'];
13 13
     @$port = $_SERVER['SERVER_PORT'];
14 14
     $fol = "";
15
-    if(@$_SERVER['SERVER_ADDR']!=NULL)
15
+    if (@$_SERVER['SERVER_ADDR'] != NULL)
16 16
     {
17 17
         $fol = "/".explode('/', $_SERVER['PHP_SELF'])[1];
18 18
     }
Please login to merge, or discard this patch.
index.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 session_start();
3
-if(isset($_SESSION['start']))
3
+if (isset($_SESSION['start']))
4 4
 {
5 5
     header("Location: account.php");
6 6
 }
Please login to merge, or discard this patch.
ajax/validate_register.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 namespace AnkitJain\RegistrationModule;
4
-require (dirname(__DIR__) . '/vendor/autoload.php');
4
+require (dirname(__DIR__).'/vendor/autoload.php');
5 5
 use AnkitJain\RegistrationModule\Register;
6 6
 @session_start();
7 7
 
8
-if(isset($_POST['q']))
8
+if (isset($_POST['q']))
9 9
 {
10 10
 	$registerField = json_decode($_POST['q']);
11 11
 	$name = $registerField->name;
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 	$password = $registerField->password;
16 16
 	$obRegister = new Register();
17 17
 	$result = $obRegister->authRegister($name, $email, $username, $password, $mob);
18
-	if(isset($result))
18
+	if (isset($result))
19 19
 		echo $result;
20 20
 	else
21 21
 		echo json_encode([]);
Please login to merge, or discard this patch.
ajax/validate_login.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,18 +1,18 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 namespace AnkitJain\RegistrationModule;
4
-require (dirname(__DIR__) . '/vendor/autoload.php');
4
+require (dirname(__DIR__).'/vendor/autoload.php');
5 5
 use AnkitJain\RegistrationModule\Login;
6 6
 @session_start();
7 7
 
8
-if(isset($_POST['q']))
8
+if (isset($_POST['q']))
9 9
 {
10 10
 	$loginField = json_decode($_POST['q']);
11 11
 	$login = $loginField->login;
12 12
 	$password = $loginField->password;
13 13
 	$obLogin = new Login();
14 14
 	$result = $obLogin->authLogin($login, $password);
15
-	if(isset($result))
15
+	if (isset($result))
16 16
 		echo $result;
17 17
 	else
18 18
 		echo json_encode([]);
Please login to merge, or discard this patch.
source/Validate.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 namespace AnkitJain\RegistrationModule;
3
-require_once (dirname(__DIR__) . '/config/database.php');
3
+require_once (dirname(__DIR__).'/config/database.php');
4 4
 
5 5
 class Validate
6 6
 {
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
 {
@@ -38,42 +38,42 @@  discard block
 block discarded – undo
38 38
 			$this->error = array_merge($this->error, ["name" => " *Enter the name"]);
39 39
 		}
40 40
 
41
-		if(empty($this->email)) {
41
+		if (empty($this->email)) {
42 42
 			$this->key = 1;
43 43
 			$this->error = array_merge($this->error, ["email" => " *Enter the email address"]);
44 44
 		}
45
-		elseif(filter_var($this->email, FILTER_VALIDATE_EMAIL) == false) {
45
+		elseif (filter_var($this->email, FILTER_VALIDATE_EMAIL) == false) {
46 46
 			$this->key = 1;
47 47
 			$this->error = array_merge($this->error, ["email" => " *Enter correct Email address"]);
48 48
 		}
49 49
 		else
50 50
 		{
51
-			if($this->obValidate->validateEmailInDb($this->email))
51
+			if ($this->obValidate->validateEmailInDb($this->email))
52 52
 			{
53 53
 				$this->key = 1;
54 54
 				$this->error = array_merge($this->error, ["email" => " *Email is already registered"]);
55 55
 			}
56 56
 		}
57 57
 
58
-		if(empty($this->username)) {
58
+		if (empty($this->username)) {
59 59
 			$this->key = 1;
60 60
 			$this->error = array_merge($this->error, ["username" => " *Enter the username"]);
61 61
 		}
62 62
 		else
63 63
 		{
64
-			if($this->obValidate->validateUsernameInDb($this->username))
64
+			if ($this->obValidate->validateUsernameInDb($this->username))
65 65
 			{
66 66
 				$this->key = 1;
67 67
 				$this->error = array_merge($this->error, ["username" => " *Username is already registered"]);
68 68
 			}
69 69
 		}
70 70
 
71
-		if(empty($this->password)) {
71
+		if (empty($this->password)) {
72 72
 			$this->key = 1;
73 73
 			$this->error = array_merge($this->error, ["password" => " *Enter the password"]);
74 74
 		}
75 75
 
76
-		if(empty($this->mob)) {
76
+		if (empty($this->mob)) {
77 77
 			$this->key = 1;
78 78
 			$this->error = array_merge($this->error, ["mob" => " *Enter the Mobile Number"]);
79 79
 		}
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 			$this->error = array_merge($this->error, ["mob" => " *Enter correct Mobile Number"]);
83 83
 		}
84 84
 
85
-		if($this->key == 1)
85
+		if ($this->key == 1)
86 86
 		{
87 87
 			return json_encode($this->error);
88 88
 		}
@@ -91,19 +91,19 @@  discard block
 block discarded – undo
91 91
 			$this->key = 0;
92 92
 			$pass = md5($this->password);
93 93
 			$query = "INSERT INTO register VALUES(null, '$this->email', '$this->username', '$pass')";
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 registration2";
97 97
 			}
98 98
 			else
99 99
 			{
100 100
 				$query = "SELECT id FROM register WHERE email = '$this->email'";
101
-				if($result = $this->connect->query($query)) {
101
+				if ($result = $this->connect->query($query)) {
102 102
 					$row = $result->fetch_assoc();
103 103
 					$UserId = $row['id'];
104 104
 
105 105
 					$query = "INSERT INTO login VALUES('$UserId', '$this->name', '$this->email', '$this->username', '$this->mob')";
106
-					if(!$this->connect->query($query)) {
106
+					if (!$this->connect->query($query)) {
107 107
 						$this->key = 1;
108 108
 						echo "You are not registered || Error in registration1";
109 109
 					}
Please login to merge, or discard this patch.
source/Login.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace AnkitJain\RegistrationModule;
3 3
 use AnkitJain\RegistrationModule\Session;
4
-require_once (dirname(__DIR__) . '/config/database.php');
4
+require_once (dirname(__DIR__).'/config/database.php');
5 5
 
6 6
 class Login
7 7
 {
@@ -25,20 +25,20 @@  discard block
 block discarded – undo
25 25
 		$this->login = trim($login);
26 26
 		$this->password = trim($password);
27 27
 
28
-		if(empty($this->login))
28
+		if (empty($this->login))
29 29
 		{
30 30
 			$this->key = 1;
31 31
 			$this->error = array_merge($this->error, ["login" => " *Enter the login field"]);
32 32
 		}
33 33
 		elseif (preg_match("/^[@]{1}$/", $this->login))
34 34
 		{
35
-			if(filter_var($this->email, FILTER_VALIDATE_EMAIL) == false)
35
+			if (filter_var($this->email, FILTER_VALIDATE_EMAIL) == false)
36 36
 			{
37 37
 			$this->key = 1;
38 38
 			$this->error = array_merge($this->error, ["login" => " *Enter correct Email address"]);
39 39
 			}
40 40
 		}
41
-		if(empty($this->password)) {
41
+		if (empty($this->password)) {
42 42
 			$this->key = 1;
43 43
 			$this->error = array_merge($this->error, ["password" => " *Enter the password"]);
44 44
 		}
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 			$pass = md5($this->password);
48 48
 		}
49 49
 
50
-		if($this->key == 0)
50
+		if ($this->key == 0)
51 51
 		{
52 52
 			$query = "SELECT * FROM login WHERE email = '$this->login' or username = '$this->login'";
53 53
 			if ($result = $this->connect->query($query))
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 					$row = $result->fetch_assoc();
58 58
 					$loginID = $row['login_id'];
59 59
 					$query = "SELECT id FROM register WHERE id = '$loginID' and password = '$pass'";
60
-					if($result = $this->connect->query($query))
60
+					if ($result = $this->connect->query($query))
61 61
 					{
62 62
 						if ($result->num_rows > 0)
63 63
 						{
Please login to merge, or discard this patch.
source/Session.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -3,17 +3,17 @@
 block discarded – undo
3 3
 namespace AnkitJain\RegistrationModule;
4 4
 @session_start();
5 5
 
6
-class Session{
6
+class Session {
7 7
 
8
-    public static function put($key, $value){
8
+    public static function put($key, $value) {
9 9
         $_SESSION[$key] = $value;
10 10
     }
11 11
 
12
-    public static function get($key){
12
+    public static function get($key) {
13 13
         return (isset($_SESSION[$key]) ? $_SESSION[$key] : null);
14 14
     }
15 15
 
16
-    public static function forget($key){
16
+    public static function forget($key) {
17 17
         unset($_SESSION[$key]);
18 18
     }
19 19
 }
Please login to merge, or discard this patch.