Test Setup Failed
Push — master ( a87e27...976b69 )
by Ankit
02:24
created
account.php 3 patches
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -12,26 +12,26 @@  discard block
 block discarded – undo
12 12
 $userId = $session->get('start');
13 13
 if($userId != null and $user == "account.php")
14 14
 {
15
-	$obUser = new User();
16
-	$row = $obUser->UserDetails($userId, True);
15
+    $obUser = new User();
16
+    $row = $obUser->UserDetails($userId, True);
17 17
 
18
-	if($row != NULL)
19
-	{
20
-		$location = URL . "/account.php/". $row['username'];
21
-		header("Location:".$location);
22
-	}
18
+    if($row != NULL)
19
+    {
20
+        $location = URL . "/account.php/". $row['username'];
21
+        header("Location:".$location);
22
+    }
23 23
 }
24 24
 elseif ($user != "account.php")
25 25
 {
26
-	$obUser = new User();
27
-	$row = $obUser->UserDetails($user, False);
28
-	if($row != NULL):
29
-		$userId = $row['login_id'];
30
-		$details = Profile::getProfile($userId);
31
-		if($details != NULL)
32
-			$row = array_merge($row, $details);
33
-		else
34
-			header("Location:".URL."/error.php");
26
+    $obUser = new User();
27
+    $row = $obUser->UserDetails($user, False);
28
+    if($row != NULL):
29
+        $userId = $row['login_id'];
30
+        $details = Profile::getProfile($userId);
31
+        if($details != NULL)
32
+            $row = array_merge($row, $details);
33
+        else
34
+            header("Location:".URL."/error.php");
35 35
 ?>
36 36
 
37 37
 		<!Doctype html>
@@ -66,18 +66,18 @@  discard block
 block discarded – undo
66 66
 						<div class="brief">
67 67
 							<h1 id="name">Name: <?php echo $row['name']; ?></h1><br>
68 68
 							<?php foreach ($row as $key => $value) {
69
-								if($key =='username' and $value != null)
70
-									echo '<p>Username: '.$row["username"] .'</p><br>';
71
-								if($key == 'email' and $value != null)
72
-									echo '<p>Email Id: '.$row["email"] .'</p><br>';
73
-								if($key == 'status' and $value != null)
74
-									echo '<p>Status: '.$row["status"] .'</p><br>';
75
-								if($key == 'education' and $value != null)
76
-									echo '<p>Education: '.$row["education"] .'</p><br>';
77
-								if($key == 'gender' and $value != null)
78
-									echo '<p>Gender: 	'.$row["gender"] .'</p><br>';
79
-							}
80
-							?>
69
+                                if($key =='username' and $value != null)
70
+                                    echo '<p>Username: '.$row["username"] .'</p><br>';
71
+                                if($key == 'email' and $value != null)
72
+                                    echo '<p>Email Id: '.$row["email"] .'</p><br>';
73
+                                if($key == 'status' and $value != null)
74
+                                    echo '<p>Status: '.$row["status"] .'</p><br>';
75
+                                if($key == 'education' and $value != null)
76
+                                    echo '<p>Education: '.$row["education"] .'</p><br>';
77
+                                if($key == 'gender' and $value != null)
78
+                                    echo '<p>Gender: 	'.$row["gender"] .'</p><br>';
79
+                            }
80
+                            ?>
81 81
 						</div>
82 82
 						<?php if($session->get('start') == $row['login_id']): ?>
83 83
 							<div class="edit">
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
 					</div>
88 88
 
89 89
 					<?php
90
-						if($session->get('start') == $row['login_id']):
91
-					?>
90
+                        if($session->get('start') == $row['login_id']):
91
+                    ?>
92 92
 
93 93
 					<div class="boxx" id="profile">
94 94
 						<form method="post" action="../profile_generate.php">
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
 						</form>
104 104
 					</div>
105 105
 					<?php
106
-						endif;
107
-					?>
106
+                        endif;
107
+                    ?>
108 108
 				</div>
109 109
 
110 110
 				<div class="footer">
@@ -117,13 +117,13 @@  discard block
 block discarded – undo
117 117
 			</body>
118 118
 		</html>
119 119
 <?php
120
-	else:
121
-		header("Location:".URL."/error.php");
122
-	endif;
120
+    else:
121
+        header("Location:".URL."/error.php");
122
+    endif;
123 123
 }
124 124
 else
125 125
 {
126
-	header("Location: ".URL);
126
+    header("Location: ".URL);
127 127
 }
128 128
 ?>
129 129
 
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -1,23 +1,23 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-require_once (__DIR__ . '/vendor/autoload.php');
4
-require_once (__DIR__ . '/config/database.php');
3
+require_once (__DIR__.'/vendor/autoload.php');
4
+require_once (__DIR__.'/config/database.php');
5 5
 use ChatApp\User;
6 6
 use ChatApp\Profile;
7 7
 use ChatApp\Session;
8 8
 
9 9
 $user = explode("/", $_SERVER['REQUEST_URI']);
10
-$user = $user[count($user)-1];
10
+$user = $user[count($user) - 1];
11 11
 $session = new Session();
12 12
 $userId = $session->get('start');
13
-if($userId != null and $user == "account.php")
13
+if ($userId != null and $user == "account.php")
14 14
 {
15 15
 	$obUser = new User();
16 16
 	$row = $obUser->UserDetails($userId, True);
17 17
 
18
-	if($row != NULL)
18
+	if ($row != NULL)
19 19
 	{
20
-		$location = URL . "/account.php/". $row['username'];
20
+		$location = URL."/account.php/".$row['username'];
21 21
 		header("Location:".$location);
22 22
 	}
23 23
 }
@@ -25,10 +25,10 @@  discard block
 block discarded – undo
25 25
 {
26 26
 	$obUser = new User();
27 27
 	$row = $obUser->UserDetails($user, False);
28
-	if($row != NULL):
28
+	if ($row != NULL):
29 29
 		$userId = $row['login_id'];
30 30
 		$details = Profile::getProfile($userId);
31
-		if($details != NULL)
31
+		if ($details != NULL)
32 32
 			$row = array_merge($row, $details);
33 33
 		else
34 34
 			header("Location:".URL."/error.php");
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 		            <a id="brand" href="">OpenChat</a>
47 47
 		            <ul class="nav-right">
48 48
 		                <li><a href="../index.php">About</a></li>
49
-		                <?php if($session->get('start') != null): ?>
49
+		                <?php if ($session->get('start') != null): ?>
50 50
 							<li><a href="../message.php">Message</a></li>
51 51
 							<li><a href="../logout.php">Log out</a></li>
52 52
 						<?php else: ?>
@@ -66,20 +66,20 @@  discard block
 block discarded – undo
66 66
 						<div class="brief">
67 67
 							<h1 id="name">Name: <?php echo $row['name']; ?></h1><br>
68 68
 							<?php foreach ($row as $key => $value) {
69
-								if($key =='username' and $value != null)
70
-									echo '<p>Username: '.$row["username"] .'</p><br>';
71
-								if($key == 'email' and $value != null)
72
-									echo '<p>Email Id: '.$row["email"] .'</p><br>';
73
-								if($key == 'status' and $value != null)
74
-									echo '<p>Status: '.$row["status"] .'</p><br>';
75
-								if($key == 'education' and $value != null)
76
-									echo '<p>Education: '.$row["education"] .'</p><br>';
77
-								if($key == 'gender' and $value != null)
78
-									echo '<p>Gender: 	'.$row["gender"] .'</p><br>';
69
+								if ($key == 'username' and $value != null)
70
+									echo '<p>Username: '.$row["username"].'</p><br>';
71
+								if ($key == 'email' and $value != null)
72
+									echo '<p>Email Id: '.$row["email"].'</p><br>';
73
+								if ($key == 'status' and $value != null)
74
+									echo '<p>Status: '.$row["status"].'</p><br>';
75
+								if ($key == 'education' and $value != null)
76
+									echo '<p>Education: '.$row["education"].'</p><br>';
77
+								if ($key == 'gender' and $value != null)
78
+									echo '<p>Gender: 	'.$row["gender"].'</p><br>';
79 79
 							}
80 80
 							?>
81 81
 						</div>
82
-						<?php if($session->get('start') == $row['login_id']): ?>
82
+						<?php if ($session->get('start') == $row['login_id']): ?>
83 83
 							<div class="edit">
84 84
 								<a href="#">Edit Profile</a>
85 85
 							</div>
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 					</div>
88 88
 
89 89
 					<?php
90
-						if($session->get('start') == $row['login_id']):
90
+						if ($session->get('start') == $row['login_id']):
91 91
 					?>
92 92
 
93 93
 					<div class="boxx" id="profile">
@@ -97,8 +97,8 @@  discard block
 block discarded – undo
97 97
 							<label>Education : </label>
98 98
 							<input type="text" name="education" id="education" value="<?php echo $row['education']; ?>"></input>
99 99
 							<label>Gender : </label><br>
100
-							<input type="radio" name="gender" id="gender" value="Male" <?php echo ($row['gender']=='Male')?'checked':'' ?>> Male<br>
101
-							<input type="radio" name="gender" id="gender" value="Female" <?php echo ($row['gender']=='Female')?'checked':'' ?>> Female<br>
100
+							<input type="radio" name="gender" id="gender" value="Male" <?php echo ($row['gender'] == 'Male') ? 'checked' : '' ?>> Male<br>
101
+							<input type="radio" name="gender" id="gender" value="Female" <?php echo ($row['gender'] == 'Female') ? 'checked' : '' ?>> Female<br>
102 102
 							<input type="submit" name="submit" value="Done" id="submit">
103 103
 						</form>
104 104
 					</div>
Please login to merge, or discard this patch.
Braces   +31 added lines, -22 removed lines patch added patch discarded remove patch
@@ -20,19 +20,19 @@  discard block
 block discarded – undo
20 20
 		$location = URL . "/account.php/". $row['username'];
21 21
 		header("Location:".$location);
22 22
 	}
23
-}
24
-elseif ($user != "account.php")
23
+} elseif ($user != "account.php")
25 24
 {
26 25
 	$obUser = new User();
27 26
 	$row = $obUser->UserDetails($user, False);
28 27
 	if($row != NULL):
29 28
 		$userId = $row['login_id'];
30 29
 		$details = Profile::getProfile($userId);
31
-		if($details != NULL)
32
-			$row = array_merge($row, $details);
33
-		else
34
-			header("Location:".URL."/error.php");
35
-?>
30
+		if($details != NULL) {
31
+					$row = array_merge($row, $details);
32
+		} else {
33
+					header("Location:".URL."/error.php");
34
+		}
35
+		?>
36 36
 
37 37
 		<!Doctype html>
38 38
 		<html>
@@ -49,10 +49,13 @@  discard block
 block discarded – undo
49 49
 		                <?php if($session->get('start') != null): ?>
50 50
 							<li><a href="../message.php">Message</a></li>
51 51
 							<li><a href="../logout.php">Log out</a></li>
52
-						<?php else: ?>
52
+						<?php else {
53
+    : ?>
53 54
 							<li><a href="../login.php">Login</a></li>
54 55
 							<li><a href="../register.php">Register</a></li>
55
-						<?php endif; ?>
56
+						<?php endif;
57
+}
58
+?>
56 59
 		            </ul>
57 60
 		        </div>
58 61
 
@@ -66,16 +69,21 @@  discard block
 block discarded – undo
66 69
 						<div class="brief">
67 70
 							<h1 id="name">Name: <?php echo $row['name']; ?></h1><br>
68 71
 							<?php foreach ($row as $key => $value) {
69
-								if($key =='username' and $value != null)
70
-									echo '<p>Username: '.$row["username"] .'</p><br>';
71
-								if($key == 'email' and $value != null)
72
-									echo '<p>Email Id: '.$row["email"] .'</p><br>';
73
-								if($key == 'status' and $value != null)
74
-									echo '<p>Status: '.$row["status"] .'</p><br>';
75
-								if($key == 'education' and $value != null)
76
-									echo '<p>Education: '.$row["education"] .'</p><br>';
77
-								if($key == 'gender' and $value != null)
78
-									echo '<p>Gender: 	'.$row["gender"] .'</p><br>';
72
+								if($key =='username' and $value != null) {
73
+																	echo '<p>Username: '.$row["username"] .'</p><br>';
74
+								}
75
+								if($key == 'email' and $value != null) {
76
+																	echo '<p>Email Id: '.$row["email"] .'</p><br>';
77
+								}
78
+								if($key == 'status' and $value != null) {
79
+																	echo '<p>Status: '.$row["status"] .'</p><br>';
80
+								}
81
+								if($key == 'education' and $value != null) {
82
+																	echo '<p>Education: '.$row["education"] .'</p><br>';
83
+								}
84
+								if($key == 'gender' and $value != null) {
85
+																	echo '<p>Gender: 	'.$row["gender"] .'</p><br>';
86
+								}
79 87
 							}
80 88
 							?>
81 89
 						</div>
@@ -117,11 +125,12 @@  discard block
 block discarded – undo
117 125
 			</body>
118 126
 		</html>
119 127
 <?php
120
-	else:
128
+	else {
129
+	    :
121 130
 		header("Location:".URL."/error.php");
131
+	}
122 132
 	endif;
123
-}
124
-else
133
+} else
125 134
 {
126 135
 	header("Location: ".URL);
127 136
 }
Please login to merge, or discard this patch.
message.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -131,6 +131,6 @@
 block discarded – undo
131 131
 <?php
132 132
 }
133 133
 else{
134
-	header('Location:http://localhost/openchat');
134
+    header('Location:http://localhost/openchat');
135 135
 }
136 136
 ?>
Please login to merge, or discard this patch.
src/Login.php 3 patches
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -7,85 +7,85 @@
 block discarded – undo
7 7
 class Login
8 8
 {
9 9
 
10
-	protected $key;
11
-	protected $error;
12
-	protected $connect;
13
-	protected $session;
10
+    protected $key;
11
+    protected $error;
12
+    protected $connect;
13
+    protected $session;
14 14
 
15
-	public function __construct()
16
-	{
17
-		$this->key = 0;
18
-		$this->connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
19
-		$this->error = array();
20
-		$this->session = new Session();
21
-	}
15
+    public function __construct()
16
+    {
17
+        $this->key = 0;
18
+        $this->connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
19
+        $this->error = array();
20
+        $this->session = new Session();
21
+    }
22 22
 
23
-	public function authLogin($login, $password)
24
-	{
23
+    public function authLogin($login, $password)
24
+    {
25 25
 
26
-		$login = trim($login);
27
-		$password = trim($password);
26
+        $login = trim($login);
27
+        $password = trim($password);
28 28
 
29
-		if(empty($login))
30
-		{
31
-			$this->key = 1;
32
-			$this->error = array_merge($this->error, ["login" => " *Enter the login field"]);
33
-		}
34
-		elseif (preg_match("/^[@]{1}$/", $login))
35
-		{
36
-			if(filter_var($login, FILTER_VALIDATE_EMAIL) == false)
37
-			{
38
-			$this->key = 1;
39
-			$this->error = array_merge($this->error, ["login" => " *Enter correct Email address"]);
40
-			}
41
-		}
42
-		if(empty($password)) {
43
-			$this->key = 1;
44
-			$this->error = array_merge($this->error, ["password" => " *Enter the password"]);
45
-		}
46
-		else
47
-		{
48
-			$password = md5($password);
49
-		}
29
+        if(empty($login))
30
+        {
31
+            $this->key = 1;
32
+            $this->error = array_merge($this->error, ["login" => " *Enter the login field"]);
33
+        }
34
+        elseif (preg_match("/^[@]{1}$/", $login))
35
+        {
36
+            if(filter_var($login, FILTER_VALIDATE_EMAIL) == false)
37
+            {
38
+            $this->key = 1;
39
+            $this->error = array_merge($this->error, ["login" => " *Enter correct Email address"]);
40
+            }
41
+        }
42
+        if(empty($password)) {
43
+            $this->key = 1;
44
+            $this->error = array_merge($this->error, ["password" => " *Enter the password"]);
45
+        }
46
+        else
47
+        {
48
+            $password = md5($password);
49
+        }
50 50
 
51
-		if($this->key == 0)
52
-		{
53
-			$query = "SELECT * FROM login WHERE email = '$login' or username = '$login'";
54
-			if ($result = $this->connect->query($query))
55
-			{
56
-				if ($result->num_rows > 0)
57
-				{
58
-					$row = $result->fetch_assoc();
59
-					$loginID = $row['login_id'];
60
-					$query = "SELECT id FROM register WHERE id = '$loginID' and password = '$password'";
61
-					if($result = $this->connect->query($query))
62
-					{
63
-						if ($result->num_rows > 0)
64
-						{
65
-							$this->session->put('start', $loginID);
66
-							return json_encode([
67
-								"location" => URL."/account.php"
68
-							]);
69
-						}
70
-						else
71
-						{
72
-							$this->error = array_merge($this->error, ["password" => " *Invalid password"]);
73
-							return json_encode($this->error);
74
-						}
75
-					}
76
-				}
77
-				else
78
-				{
79
-					$this->error = array_merge($this->error, ["login" => " *Invalid username or email"]);
80
-					return json_encode($this->error);
81
-				}
82
-			}
51
+        if($this->key == 0)
52
+        {
53
+            $query = "SELECT * FROM login WHERE email = '$login' or username = '$login'";
54
+            if ($result = $this->connect->query($query))
55
+            {
56
+                if ($result->num_rows > 0)
57
+                {
58
+                    $row = $result->fetch_assoc();
59
+                    $loginID = $row['login_id'];
60
+                    $query = "SELECT id FROM register WHERE id = '$loginID' and password = '$password'";
61
+                    if($result = $this->connect->query($query))
62
+                    {
63
+                        if ($result->num_rows > 0)
64
+                        {
65
+                            $this->session->put('start', $loginID);
66
+                            return json_encode([
67
+                                "location" => URL."/account.php"
68
+                            ]);
69
+                        }
70
+                        else
71
+                        {
72
+                            $this->error = array_merge($this->error, ["password" => " *Invalid password"]);
73
+                            return json_encode($this->error);
74
+                        }
75
+                    }
76
+                }
77
+                else
78
+                {
79
+                    $this->error = array_merge($this->error, ["login" => " *Invalid username or email"]);
80
+                    return json_encode($this->error);
81
+                }
82
+            }
83 83
 
84
-		}
85
-		else
86
-		{
87
-			return json_encode($this->error);
88
-		}
89
-		$this->connect->close();
90
-	}
84
+        }
85
+        else
86
+        {
87
+            return json_encode($this->error);
88
+        }
89
+        $this->connect->close();
90
+    }
91 91
 }
Please login to merge, or discard this 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 ChatApp;
4 4
 use ChatApp\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
 {
@@ -26,20 +26,20 @@  discard block
 block discarded – undo
26 26
 		$login = trim($login);
27 27
 		$password = trim($password);
28 28
 
29
-		if(empty($login))
29
+		if (empty($login))
30 30
 		{
31 31
 			$this->key = 1;
32 32
 			$this->error = array_merge($this->error, ["login" => " *Enter the login field"]);
33 33
 		}
34 34
 		elseif (preg_match("/^[@]{1}$/", $login))
35 35
 		{
36
-			if(filter_var($login, FILTER_VALIDATE_EMAIL) == false)
36
+			if (filter_var($login, FILTER_VALIDATE_EMAIL) == false)
37 37
 			{
38 38
 			$this->key = 1;
39 39
 			$this->error = array_merge($this->error, ["login" => " *Enter correct Email address"]);
40 40
 			}
41 41
 		}
42
-		if(empty($password)) {
42
+		if (empty($password)) {
43 43
 			$this->key = 1;
44 44
 			$this->error = array_merge($this->error, ["password" => " *Enter the password"]);
45 45
 		}
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 			$password = md5($password);
49 49
 		}
50 50
 
51
-		if($this->key == 0)
51
+		if ($this->key == 0)
52 52
 		{
53 53
 			$query = "SELECT * FROM login WHERE email = '$login' or username = '$login'";
54 54
 			if ($result = $this->connect->query($query))
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 					$row = $result->fetch_assoc();
59 59
 					$loginID = $row['login_id'];
60 60
 					$query = "SELECT id FROM register WHERE id = '$loginID' and password = '$password'";
61
-					if($result = $this->connect->query($query))
61
+					if ($result = $this->connect->query($query))
62 62
 					{
63 63
 						if ($result->num_rows > 0)
64 64
 						{
Please login to merge, or discard this patch.
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -30,8 +30,7 @@  discard block
 block discarded – undo
30 30
 		{
31 31
 			$this->key = 1;
32 32
 			$this->error = array_merge($this->error, ["login" => " *Enter the login field"]);
33
-		}
34
-		elseif (preg_match("/^[@]{1}$/", $login))
33
+		} elseif (preg_match("/^[@]{1}$/", $login))
35 34
 		{
36 35
 			if(filter_var($login, FILTER_VALIDATE_EMAIL) == false)
37 36
 			{
@@ -42,8 +41,7 @@  discard block
 block discarded – undo
42 41
 		if(empty($password)) {
43 42
 			$this->key = 1;
44 43
 			$this->error = array_merge($this->error, ["password" => " *Enter the password"]);
45
-		}
46
-		else
44
+		} else
47 45
 		{
48 46
 			$password = md5($password);
49 47
 		}
@@ -66,23 +64,20 @@  discard block
 block discarded – undo
66 64
 							return json_encode([
67 65
 								"location" => URL."/account.php"
68 66
 							]);
69
-						}
70
-						else
67
+						} else
71 68
 						{
72 69
 							$this->error = array_merge($this->error, ["password" => " *Invalid password"]);
73 70
 							return json_encode($this->error);
74 71
 						}
75 72
 					}
76
-				}
77
-				else
73
+				} else
78 74
 				{
79 75
 					$this->error = array_merge($this->error, ["login" => " *Invalid username or email"]);
80 76
 					return json_encode($this->error);
81 77
 				}
82 78
 			}
83 79
 
84
-		}
85
-		else
80
+		} else
86 81
 		{
87 82
 			return json_encode($this->error);
88 83
 		}
Please login to merge, or discard this patch.
src/Search.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 namespace ChatApp;
4
-require_once (dirname(__DIR__) . '/config/database.php');
4
+require_once (dirname(__DIR__).'/config/database.php');
5 5
 use ChatApp\Time;
6 6
 
7 7
 /**
@@ -28,24 +28,24 @@  discard block
 block discarded – undo
28 28
     {
29 29
         $suggestion = $suggestion->value;
30 30
         $flag = 0;
31
-        if(isset($_SESSION['start']) && isset($suggestion))
31
+        if (isset($_SESSION['start']) && isset($suggestion))
32 32
         {
33 33
             $id = $_SESSION['start'];
34 34
             $suggestion = trim($suggestion);
35
-            if($suggestion != "")
35
+            if ($suggestion != "")
36 36
             {
37 37
                 $query = "SELECT * FROM login where login_id != '$id' and name like '$suggestion%' ORDER BY name ASC";
38
-                if($result = $this->connect->query($query))
38
+                if ($result = $this->connect->query($query))
39 39
                 {
40
-                    if($result->num_rows > 0)
40
+                    if ($result->num_rows > 0)
41 41
                     {
42
-                        while($row = $result->fetch_assoc())
42
+                        while ($row = $result->fetch_assoc())
43 43
                         {
44 44
                             $check_id = $row["login_id"];
45 45
                             $query = "SELECT * from total_message where (user1 = '$check_id' and user2 = '$id') or (user2 = '$check_id' and user1 = '$id')";
46
-                            if($result1 = $this->connect->query($query))
46
+                            if ($result1 = $this->connect->query($query))
47 47
                             {
48
-                                if($result1->num_rows > 0)
48
+                                if ($result1->num_rows > 0)
49 49
                                 {
50 50
                                     $fetch = $result1->fetch_assoc();
51 51
                                     $fetch['time'] = $this->obTime->TimeConversion($fetch['time']);
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
                         }
58 58
                     }
59 59
                 }
60
-                if($flag != 0)
60
+                if ($flag != 0)
61 61
                 {
62 62
                     $this->array = array_merge([], ["Search" => $this->array]);
63 63
                     return json_encode($this->array);
Please login to merge, or discard this patch.
src/Session.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -3,22 +3,22 @@
 block discarded – undo
3 3
 namespace ChatApp;
4 4
 session_start();
5 5
 
6
-class Session{
6
+class Session {
7 7
 
8 8
     public function __construct()
9 9
     {
10 10
         # code
11 11
     }
12 12
 
13
-    public function put($key, $value){
13
+    public function put($key, $value) {
14 14
         $_SESSION[$key] = $value;
15 15
     }
16 16
 
17
-    public function get($key){
17
+    public function get($key) {
18 18
         return (isset($_SESSION[$key]) ? $_SESSION[$key] : null);
19 19
     }
20 20
 
21
-    public function forget($key){
21
+    public function forget($key) {
22 22
         unset($_SESSION[$key]);
23 23
     }
24 24
 }
Please login to merge, or discard this patch.
src/Reply.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 namespace ChatApp;
4
-require_once (dirname(__DIR__) . '/config/database.php');
4
+require_once (dirname(__DIR__).'/config/database.php');
5 5
 
6 6
 /**
7 7
 * Store Message in the Database
@@ -21,37 +21,37 @@  discard block
 block discarded – undo
21 21
     public function replyTo($msg)
22 22
     {
23 23
 
24
-        if(isset($_SESSION['start']) && isset($msg))  //checks for session login and the value send
24
+        if (isset($_SESSION['start']) && isset($msg))  //checks for session login and the value send
25 25
         {
26 26
             $id = $_SESSION['start'];
27
-            $msg = json_decode($msg);   //decode json value
27
+            $msg = json_decode($msg); //decode json value
28 28
             $identifier = $msg->name;
29 29
 
30
-            $receiverID = $identifier;  //stores id of the person whom message is to be sent
30
+            $receiverID = $identifier; //stores id of the person whom message is to be sent
31 31
 
32
-            if($identifier > $id)    // geneate specific unique code to store messages
32
+            if ($identifier > $id)    // geneate specific unique code to store messages
33 33
                 $identifier = $id.":".$identifier;
34 34
             else
35 35
                 $identifier = $identifier.":".$id;
36 36
 
37 37
             $reply = addslashes(trim($msg->reply[0])); // stores the message sent by the user.
38 38
 
39
-            $time = date("D d M Y H:i:s", time() + 16200);  // current time
39
+            $time = date("D d M Y H:i:s", time() + 16200); // current time
40 40
             $time_id = date("YmdHis", time() + 16200); //to sort the array on the basis of time
41 41
 
42 42
             //the sender id must not be equal to current session id
43
-            if($reply != "" && $receiverID != $id)
43
+            if ($reply != "" && $receiverID != $id)
44 44
             {
45 45
                 // check whether the receiver is authorized or registered
46 46
                 $query = "SELECT * from login where login_id = '$receiverID'";
47 47
 
48 48
                 $result = $this->connect->query($query);
49
-                if($result->num_rows > 0)     // if true
49
+                if ($result->num_rows > 0)     // if true
50 50
                 {
51 51
                     //check whether he is sending message for thr first time or he has sent messages before
52 52
                     $query = "SELECT * from total_message where identifier = '$identifier'";
53 53
                     $result = $this->connect->query($query);
54
-                    if($result->num_rows>0)               // if he has sent messages before
54
+                    if ($result->num_rows > 0)               // if he has sent messages before
55 55
                     {
56 56
                         // Update Total_Message Table
57 57
                         $query = "UPDATE total_message SET total_messages = total_messages+1, time = '$time', unread = 1, id = '$time_id' WHERE identifier = '$identifier'";
@@ -61,15 +61,15 @@  discard block
 block discarded – undo
61 61
                     else    // if he sends message for the first time
62 62
                     {
63 63
                         $length = strlen($id);
64
-                        if(substr($identifier, 0, $length) == $id) // generate specific unique code
64
+                        if (substr($identifier, 0, $length) == $id) // generate specific unique code
65 65
                         {
66
-                            $user2 = substr($identifier, $length+1);
66
+                            $user2 = substr($identifier, $length + 1);
67 67
                             $user1 = $id;
68 68
                         }
69 69
                         else
70 70
                         {
71 71
                             $user2 = $id;
72
-                            $length = strlen($identifier) - $length-1;
72
+                            $length = strlen($identifier) - $length - 1;
73 73
                             $user1 = substr($identifier, 0, $length);
74 74
                         }
75 75
                         // insert Details in Total_Message Table
@@ -92,13 +92,13 @@  discard block
 block discarded – undo
92 92
 
93 93
     public function UpdateMessages($query, $identifier, $reply, $id, $time)
94 94
     {
95
-        if($result = $this->connect->query($query))
95
+        if ($result = $this->connect->query($query))
96 96
         {
97 97
             //insert message in db
98 98
             $query = "INSERT into messages values('$identifier', '$reply', '$id', '$time', null)";
99
-            if($result = $this->connect->query($query))
99
+            if ($result = $this->connect->query($query))
100 100
             {
101
-                echo "Messages is sent \n";    // if query is executed return true
101
+                echo "Messages is sent \n"; // if query is executed return true
102 102
             }
103 103
             else
104 104
             {
Please login to merge, or discard this patch.
src/Conversation.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 namespace ChatApp;
4
-require_once (dirname(__DIR__) . '/config/database.php');
4
+require_once (dirname(__DIR__).'/config/database.php');
5 5
 use ChatApp\Time;
6 6
 use ChatApp\User;
7 7
 
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
     {
31 31
 
32 32
         $flag = 1;
33
-        if(isset($_SESSION['start']) && isset($msg))
33
+        if (isset($_SESSION['start']) && isset($msg))
34 34
         {
35 35
             $add_load = 0;
36 36
             $id = $_SESSION['start'];
@@ -40,25 +40,25 @@  discard block
 block discarded – undo
40 40
 
41 41
             $fetch = $this->obUser->UserDetails($username, $para);
42 42
 
43
-            if($fetch != NULL)
43
+            if ($fetch != NULL)
44 44
             {
45 45
                 $login_id = (int)$fetch['login_id'];
46 46
 
47 47
                 // Unique Identifier
48
-                if($login_id > $id)
48
+                if ($login_id > $id)
49 49
                     $identifier = $id.':'.$login_id;
50 50
                 else
51 51
                     $identifier = $login_id.':'.$id;
52 52
 
53 53
                 $query = "SELECT total_messages from total_message where identifier = '$identifier'";
54
-                if($result = $this->connect->query($query))
54
+                if ($result = $this->connect->query($query))
55 55
                 {
56
-                    if($result->num_rows > 0)
56
+                    if ($result->num_rows > 0)
57 57
                     {
58 58
                         $total = $result->fetch_assoc();
59 59
                         $total = $total['total_messages'];
60
-                        if($total - $load > 0)
61
-                            if($total - $load > 10)
60
+                        if ($total - $load > 0)
61
+                            if ($total - $load > 10)
62 62
                                 $add_load = $load + 10;
63 63
                             else
64 64
                                 $add_load = $total;
@@ -66,14 +66,14 @@  discard block
 block discarded – undo
66 66
                 }
67 67
 
68 68
                 $query = "SELECT message, time, sent_by FROM messages WHERE identifier_message_number = '$identifier' ORDER BY id DESC limit ".$load;
69
-                if($result = $this->connect->query($query))
69
+                if ($result = $this->connect->query($query))
70 70
                 {
71
-                    if($result->num_rows > 0)
71
+                    if ($result->num_rows > 0)
72 72
                     {
73
-                        while($row = $result->fetch_assoc())
73
+                        while ($row = $result->fetch_assoc())
74 74
                         {
75 75
                             $row['time'] = $this->obTime->TimeConversion($row['time']);
76
-                            $row = array_merge($row,['start' => $id]);
76
+                            $row = array_merge($row, ['start' => $id]);
77 77
                             $this->array = array_merge($this->array, [$row]);
78 78
                         }
79 79
 
Please login to merge, or discard this patch.
src/Register.php 3 patches
Indentation   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -7,116 +7,116 @@
 block discarded – undo
7 7
 
8 8
 class Register
9 9
 {
10
-	protected $error;
11
-	protected $key;
12
-	protected $obValidate;
13
-	protected $connect;
14
-	protected $session;
10
+    protected $error;
11
+    protected $key;
12
+    protected $obValidate;
13
+    protected $connect;
14
+    protected $session;
15 15
 
16
-	public function __construct()
17
-	{
18
-		$this->error = array();
19
-		$this->key = 0;
20
-		$this->connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
21
-		$this->session = new Session();
22
-		$this->obValidate = new Validate();
16
+    public function __construct()
17
+    {
18
+        $this->error = array();
19
+        $this->key = 0;
20
+        $this->connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
21
+        $this->session = new Session();
22
+        $this->obValidate = new Validate();
23 23
 
24
-	}
24
+    }
25 25
 
26
-	public function authRegister($name, $email, $username, $password, $mob)
27
-	{
28
-		$name = trim($name);
29
-		$email = trim($email);
30
-		$username = trim($username);
31
-		$password = trim($password);
32
-		$mob = trim($mob);
33
-		$userId = '';
26
+    public function authRegister($name, $email, $username, $password, $mob)
27
+    {
28
+        $name = trim($name);
29
+        $email = trim($email);
30
+        $username = trim($username);
31
+        $password = trim($password);
32
+        $mob = trim($mob);
33
+        $userId = '';
34 34
 
35
-		if (empty($name)) {
36
-			$this->onError(["name" => " *Enter the name"]);
37
-		}
35
+        if (empty($name)) {
36
+            $this->onError(["name" => " *Enter the name"]);
37
+        }
38 38
 
39
-		if(empty($email)) {
40
-			$this->onError(["email" => " *Enter the email address"]);
41
-		}
42
-		elseif(filter_var($email, FILTER_VALIDATE_EMAIL) == false) {
43
-			$this->onError(["email" => " *Enter correct Email address"]);
44
-		}
45
-		else
46
-		{
47
-			if($this->obValidate->validateEmailInDb($email) === 1)
48
-			{
39
+        if(empty($email)) {
40
+            $this->onError(["email" => " *Enter the email address"]);
41
+        }
42
+        elseif(filter_var($email, FILTER_VALIDATE_EMAIL) == false) {
43
+            $this->onError(["email" => " *Enter correct Email address"]);
44
+        }
45
+        else
46
+        {
47
+            if($this->obValidate->validateEmailInDb($email) === 1)
48
+            {
49 49
 
50
-				$this->onError(["email" => " *Email is already registered"]);
51
-			}
52
-		}
50
+                $this->onError(["email" => " *Email is already registered"]);
51
+            }
52
+        }
53 53
 
54
-		if(empty($username)) {
55
-			$this->onError(["username" => " *Enter the username"]);
56
-		}
57
-		else
58
-		{
59
-			if($this->obValidate->validateUsernameInDb($username) === 1)
60
-			{
54
+        if(empty($username)) {
55
+            $this->onError(["username" => " *Enter the username"]);
56
+        }
57
+        else
58
+        {
59
+            if($this->obValidate->validateUsernameInDb($username) === 1)
60
+            {
61 61
 
62
-				$this->onError(["username" => " *Username is already registered"]);
63
-			}
64
-		}
62
+                $this->onError(["username" => " *Username is already registered"]);
63
+            }
64
+        }
65 65
 
66
-		if(empty($password)) {
67
-			$this->onError(["password" => " *Enter the password"]);
68
-		}
66
+        if(empty($password)) {
67
+            $this->onError(["password" => " *Enter the password"]);
68
+        }
69 69
 
70
-		if(empty($mob)) {
71
-			$this->onError(["mob" => " *Enter the Mobile Number"]);
72
-		}
73
-		elseif (!preg_match("/^[0-9]{10}$/", $mob)) {
74
-			$this->onError(["mob" => " *Enter correct Mobile Number"]);
75
-		}
70
+        if(empty($mob)) {
71
+            $this->onError(["mob" => " *Enter the Mobile Number"]);
72
+        }
73
+        elseif (!preg_match("/^[0-9]{10}$/", $mob)) {
74
+            $this->onError(["mob" => " *Enter correct Mobile Number"]);
75
+        }
76 76
 
77
-		if($this->key == 1)
78
-		{
79
-			return json_encode($this->error);
80
-		}
81
-		else
82
-		{
83
-			$this->key = 0;
84
-			$pass = md5($password);
85
-			$query = "INSERT INTO register VALUES(null, '$email', '$username', '$pass')";
86
-			if(!$this->connect->query($query)) {
87
-				$this->key = 1;
88
-				echo "You are not registered || Error in registration2";
89
-			}
90
-			else
91
-			{
92
-				$query = "SELECT id FROM register WHERE email = '$email'";
93
-				if($result = $this->connect->query($query)) {
94
-					$row = $result->fetch_assoc();
95
-					$userId = $row['id'];
77
+        if($this->key == 1)
78
+        {
79
+            return json_encode($this->error);
80
+        }
81
+        else
82
+        {
83
+            $this->key = 0;
84
+            $pass = md5($password);
85
+            $query = "INSERT INTO register VALUES(null, '$email', '$username', '$pass')";
86
+            if(!$this->connect->query($query)) {
87
+                $this->key = 1;
88
+                echo "You are not registered || Error in registration2";
89
+            }
90
+            else
91
+            {
92
+                $query = "SELECT id FROM register WHERE email = '$email'";
93
+                if($result = $this->connect->query($query)) {
94
+                    $row = $result->fetch_assoc();
95
+                    $userId = $row['id'];
96 96
 
97
-					$query = "INSERT INTO login VALUES('$userId', '$name', '$email', '$username', '$mob', 0)";
98
-					if(!$this->connect->query($query)) {
99
-						$this->key = 1;
100
-						echo "You are not registered || Error in registration1";
101
-					}
102
-				}
103
-			}
104
-		}
105
-		if ($this->key == 0) {
106
-			$this->session->put('start', $userId);
107
-			return json_encode([
108
-				"location" => URL."/account.php"
109
-			]);
110
-		}
111
-		else
112
-		{
113
-			return json_encode($this->error);
114
-		}
115
-	}
97
+                    $query = "INSERT INTO login VALUES('$userId', '$name', '$email', '$username', '$mob', 0)";
98
+                    if(!$this->connect->query($query)) {
99
+                        $this->key = 1;
100
+                        echo "You are not registered || Error in registration1";
101
+                    }
102
+                }
103
+            }
104
+        }
105
+        if ($this->key == 0) {
106
+            $this->session->put('start', $userId);
107
+            return json_encode([
108
+                "location" => URL."/account.php"
109
+            ]);
110
+        }
111
+        else
112
+        {
113
+            return json_encode($this->error);
114
+        }
115
+    }
116 116
 
117
-	public function onError($value)
118
-	{
119
-		$this->key = 1;
120
-		$this->error = array_merge($this->error, $value);
121
-	}
117
+    public function onError($value)
118
+    {
119
+        $this->key = 1;
120
+        $this->error = array_merge($this->error, $value);
121
+    }
122 122
 }
Please login to merge, or discard this 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 ChatApp;
4 4
 use ChatApp\Validate;
5 5
 use ChatApp\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
 {
@@ -36,45 +36,45 @@  discard block
 block discarded – undo
36 36
 			$this->onError(["name" => " *Enter the name"]);
37 37
 		}
38 38
 
39
-		if(empty($email)) {
39
+		if (empty($email)) {
40 40
 			$this->onError(["email" => " *Enter the email address"]);
41 41
 		}
42
-		elseif(filter_var($email, FILTER_VALIDATE_EMAIL) == false) {
42
+		elseif (filter_var($email, FILTER_VALIDATE_EMAIL) == false) {
43 43
 			$this->onError(["email" => " *Enter correct Email address"]);
44 44
 		}
45 45
 		else
46 46
 		{
47
-			if($this->obValidate->validateEmailInDb($email) === 1)
47
+			if ($this->obValidate->validateEmailInDb($email) === 1)
48 48
 			{
49 49
 
50 50
 				$this->onError(["email" => " *Email is already registered"]);
51 51
 			}
52 52
 		}
53 53
 
54
-		if(empty($username)) {
54
+		if (empty($username)) {
55 55
 			$this->onError(["username" => " *Enter the username"]);
56 56
 		}
57 57
 		else
58 58
 		{
59
-			if($this->obValidate->validateUsernameInDb($username) === 1)
59
+			if ($this->obValidate->validateUsernameInDb($username) === 1)
60 60
 			{
61 61
 
62 62
 				$this->onError(["username" => " *Username is already registered"]);
63 63
 			}
64 64
 		}
65 65
 
66
-		if(empty($password)) {
66
+		if (empty($password)) {
67 67
 			$this->onError(["password" => " *Enter the password"]);
68 68
 		}
69 69
 
70
-		if(empty($mob)) {
70
+		if (empty($mob)) {
71 71
 			$this->onError(["mob" => " *Enter the Mobile Number"]);
72 72
 		}
73 73
 		elseif (!preg_match("/^[0-9]{10}$/", $mob)) {
74 74
 			$this->onError(["mob" => " *Enter correct Mobile Number"]);
75 75
 		}
76 76
 
77
-		if($this->key == 1)
77
+		if ($this->key == 1)
78 78
 		{
79 79
 			return json_encode($this->error);
80 80
 		}
@@ -83,19 +83,19 @@  discard block
 block discarded – undo
83 83
 			$this->key = 0;
84 84
 			$pass = md5($password);
85 85
 			$query = "INSERT INTO register VALUES(null, '$email', '$username', '$pass')";
86
-			if(!$this->connect->query($query)) {
86
+			if (!$this->connect->query($query)) {
87 87
 				$this->key = 1;
88 88
 				echo "You are not registered || Error in registration2";
89 89
 			}
90 90
 			else
91 91
 			{
92 92
 				$query = "SELECT id FROM register WHERE email = '$email'";
93
-				if($result = $this->connect->query($query)) {
93
+				if ($result = $this->connect->query($query)) {
94 94
 					$row = $result->fetch_assoc();
95 95
 					$userId = $row['id'];
96 96
 
97 97
 					$query = "INSERT INTO login VALUES('$userId', '$name', '$email', '$username', '$mob', 0)";
98
-					if(!$this->connect->query($query)) {
98
+					if (!$this->connect->query($query)) {
99 99
 						$this->key = 1;
100 100
 						echo "You are not registered || Error in registration1";
101 101
 					}
Please login to merge, or discard this patch.
Braces   +7 added lines, -14 removed lines patch added patch discarded remove patch
@@ -38,11 +38,9 @@  discard block
 block discarded – undo
38 38
 
39 39
 		if(empty($email)) {
40 40
 			$this->onError(["email" => " *Enter the email address"]);
41
-		}
42
-		elseif(filter_var($email, FILTER_VALIDATE_EMAIL) == false) {
41
+		} elseif(filter_var($email, FILTER_VALIDATE_EMAIL) == false) {
43 42
 			$this->onError(["email" => " *Enter correct Email address"]);
44
-		}
45
-		else
43
+		} else
46 44
 		{
47 45
 			if($this->obValidate->validateEmailInDb($email) === 1)
48 46
 			{
@@ -53,8 +51,7 @@  discard block
 block discarded – undo
53 51
 
54 52
 		if(empty($username)) {
55 53
 			$this->onError(["username" => " *Enter the username"]);
56
-		}
57
-		else
54
+		} else
58 55
 		{
59 56
 			if($this->obValidate->validateUsernameInDb($username) === 1)
60 57
 			{
@@ -69,16 +66,14 @@  discard block
 block discarded – undo
69 66
 
70 67
 		if(empty($mob)) {
71 68
 			$this->onError(["mob" => " *Enter the Mobile Number"]);
72
-		}
73
-		elseif (!preg_match("/^[0-9]{10}$/", $mob)) {
69
+		} elseif (!preg_match("/^[0-9]{10}$/", $mob)) {
74 70
 			$this->onError(["mob" => " *Enter correct Mobile Number"]);
75 71
 		}
76 72
 
77 73
 		if($this->key == 1)
78 74
 		{
79 75
 			return json_encode($this->error);
80
-		}
81
-		else
76
+		} else
82 77
 		{
83 78
 			$this->key = 0;
84 79
 			$pass = md5($password);
@@ -86,8 +81,7 @@  discard block
 block discarded – undo
86 81
 			if(!$this->connect->query($query)) {
87 82
 				$this->key = 1;
88 83
 				echo "You are not registered || Error in registration2";
89
-			}
90
-			else
84
+			} else
91 85
 			{
92 86
 				$query = "SELECT id FROM register WHERE email = '$email'";
93 87
 				if($result = $this->connect->query($query)) {
@@ -107,8 +101,7 @@  discard block
 block discarded – undo
107 101
 			return json_encode([
108 102
 				"location" => URL."/account.php"
109 103
 			]);
110
-		}
111
-		else
104
+		} else
112 105
 		{
113 106
 			return json_encode($this->error);
114 107
 		}
Please login to merge, or discard this patch.
src/Validate.php 2 patches
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -4,35 +4,35 @@
 block discarded – undo
4 4
 
5 5
 class Validate
6 6
 {
7
-	protected $connect;
7
+    protected $connect;
8 8
 
9
-	public function __construct()
10
-	{
11
-		$this->connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
12
-	}
9
+    public function __construct()
10
+    {
11
+        $this->connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
12
+    }
13 13
 
14
-	public function validateEmailInDb($email)
15
-	{
16
-		$query = "SELECT login_id FROM login WHERE email = '$email'";
17
-		if ($result = $this->connect->query($query))
18
-		{
19
-			if ($result->num_rows > 0) {
20
-				return 1;
21
-			}
22
-			else
23
-				return 0;
24
-		}
25
-	}
14
+    public function validateEmailInDb($email)
15
+    {
16
+        $query = "SELECT login_id FROM login WHERE email = '$email'";
17
+        if ($result = $this->connect->query($query))
18
+        {
19
+            if ($result->num_rows > 0) {
20
+                return 1;
21
+            }
22
+            else
23
+                return 0;
24
+        }
25
+    }
26 26
 
27
-	function validateUsernameInDb($username)
28
-	{
29
-		$query = "SELECT login_id FROM login WHERE username = '$username'";
30
-		if ($result = $this->connect->query($query)) {
31
-			if ($result->num_rows > 0) {
32
-				return 1;
33
-			}
34
-			else
35
-				return 0;
36
-		}
37
-	}
27
+    function validateUsernameInDb($username)
28
+    {
29
+        $query = "SELECT login_id FROM login WHERE username = '$username'";
30
+        if ($result = $this->connect->query($query)) {
31
+            if ($result->num_rows > 0) {
32
+                return 1;
33
+            }
34
+            else
35
+                return 0;
36
+        }
37
+    }
38 38
 }
Please login to merge, or discard this 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 ChatApp;
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.