Completed
Push — master ( 37eca5...0dfdea )
by Ankit
02:50
created
profile_generate.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,21 +1,21 @@
 block discarded – undo
1 1
 <?php
2
-require_once (__DIR__ . '/config/database.php');
3
-require_once (__DIR__ . '/vendor/autoload.php');
2
+require_once (__DIR__.'/config/database.php');
3
+require_once (__DIR__.'/vendor/autoload.php');
4 4
 use ChatApp\Session;
5 5
 use ChatApp\Profile;
6 6
 
7 7
 $connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
8 8
 $userId = Session::get('start');
9 9
 $data = '';
10
-if(isset($_POST['submit']))
10
+if (isset($_POST['submit']))
11 11
 {
12 12
 	$data = Profile::getProfile($userId);
13
-	if($data != NULL):
13
+	if ($data != NULL):
14 14
 		$status = get($_POST['status'], $data['status']);
15 15
 		$edu = get($_POST['education'], $data['education']);
16 16
 		$gender = get($_POST['gender'], $data['gender']);
17 17
 		$query = "UPDATE profile set status='$status', education='$edu', gender='$gender' where login_id = '$userId'";
18
-		if($result = $connect->query($query))
18
+		if ($result = $connect->query($query))
19 19
 		{
20 20
 			header('Location:'.URL.'/account.php');
21 21
 		}
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -18,14 +18,12 @@
 block discarded – undo
18 18
 		if($result = $connect->query($query))
19 19
 		{
20 20
 			header('Location:'.URL.'/account.php');
21
-		}
22
-		else
21
+		} else
23 22
 		{
24 23
 			header("Location:".URL."/error.php");
25 24
 		}
26 25
 	endif;
27
-}
28
-else
26
+} else
29 27
 {
30 28
 	header("Location:".URL."/error.php");
31 29
 }
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', 'openchat');
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.
src/Register.php 2 patches
Spacing   +13 added lines, -13 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
 {
@@ -34,45 +34,45 @@  discard block
 block discarded – undo
34 34
 			$this->onError(["name" => " *Enter the name"]);
35 35
 		}
36 36
 
37
-		if(empty($email)) {
37
+		if (empty($email)) {
38 38
 			$this->onError(["email" => " *Enter the email address"]);
39 39
 		}
40
-		elseif(filter_var($email, FILTER_VALIDATE_EMAIL) == false) {
40
+		elseif (filter_var($email, FILTER_VALIDATE_EMAIL) == false) {
41 41
 			$this->onError(["email" => " *Enter correct Email address"]);
42 42
 		}
43 43
 		else
44 44
 		{
45
-			if($this->obValidate->validateEmailInDb($email) === 1)
45
+			if ($this->obValidate->validateEmailInDb($email) === 1)
46 46
 			{
47 47
 
48 48
 				$this->onError(["email" => " *Email is already registered"]);
49 49
 			}
50 50
 		}
51 51
 
52
-		if(empty($username)) {
52
+		if (empty($username)) {
53 53
 			$this->onError(["username" => " *Enter the username"]);
54 54
 		}
55 55
 		else
56 56
 		{
57
-			if($this->obValidate->validateUsernameInDb($username) === 1)
57
+			if ($this->obValidate->validateUsernameInDb($username) === 1)
58 58
 			{
59 59
 
60 60
 				$this->onError(["username" => " *Username is already registered"]);
61 61
 			}
62 62
 		}
63 63
 
64
-		if(empty($password)) {
64
+		if (empty($password)) {
65 65
 			$this->onError(["password" => " *Enter the password"]);
66 66
 		}
67 67
 
68
-		if(empty($mob)) {
68
+		if (empty($mob)) {
69 69
 			$this->onError(["mob" => " *Enter the Mobile Number"]);
70 70
 		}
71 71
 		elseif (!preg_match("/^[0-9]{10}$/", $mob)) {
72 72
 			$this->onError(["mob" => " *Enter correct Mobile Number"]);
73 73
 		}
74 74
 
75
-		if($this->key == 1)
75
+		if ($this->key == 1)
76 76
 		{
77 77
 			return json_encode($this->error);
78 78
 		}
@@ -81,26 +81,26 @@  discard block
 block discarded – undo
81 81
 			$this->key = 0;
82 82
 			$pass = md5($password);
83 83
 			$query = "INSERT INTO register VALUES(null, '$email', '$username', '$pass')";
84
-			if(!$this->connect->query($query)) {
84
+			if (!$this->connect->query($query)) {
85 85
 				$this->key = 1;
86 86
 				echo "You are not registered || Error in registration1";
87 87
 			}
88 88
 			else
89 89
 			{
90 90
 				$query = "SELECT id FROM register WHERE email = '$email'";
91
-				if($result = $this->connect->query($query)) {
91
+				if ($result = $this->connect->query($query)) {
92 92
 					$row = $result->fetch_assoc();
93 93
 					$userId = $row['id'];
94 94
 
95 95
 					$query = "INSERT INTO login VALUES('$userId', '$name', '$email', '$username', '$mob', 0)";
96
-					if(!$this->connect->query($query)) {
96
+					if (!$this->connect->query($query)) {
97 97
 						$this->key = 1;
98 98
 						echo "You are not registered || Error in registration2";
99 99
 					}
100 100
 					else
101 101
 					{
102 102
 						$query = "INSERT INTO profile VALUES('$userId', 'Joined OpenChat', 'Joined OpenChat', '')";
103
-						if(!$this->connect->query($query)) {
103
+						if (!$this->connect->query($query)) {
104 104
 							$this->key = 1;
105 105
 							echo "You are not registered || Error in registration3";
106 106
 						}
Please login to merge, or discard this patch.
Braces   +8 added lines, -16 removed lines patch added patch discarded remove patch
@@ -36,11 +36,9 @@  discard block
 block discarded – undo
36 36
 
37 37
 		if(empty($email)) {
38 38
 			$this->onError(["email" => " *Enter the email address"]);
39
-		}
40
-		elseif(filter_var($email, FILTER_VALIDATE_EMAIL) == false) {
39
+		} elseif(filter_var($email, FILTER_VALIDATE_EMAIL) == false) {
41 40
 			$this->onError(["email" => " *Enter correct Email address"]);
42
-		}
43
-		else
41
+		} else
44 42
 		{
45 43
 			if($this->obValidate->validateEmailInDb($email) === 1)
46 44
 			{
@@ -51,8 +49,7 @@  discard block
 block discarded – undo
51 49
 
52 50
 		if(empty($username)) {
53 51
 			$this->onError(["username" => " *Enter the username"]);
54
-		}
55
-		else
52
+		} else
56 53
 		{
57 54
 			if($this->obValidate->validateUsernameInDb($username) === 1)
58 55
 			{
@@ -67,16 +64,14 @@  discard block
 block discarded – undo
67 64
 
68 65
 		if(empty($mob)) {
69 66
 			$this->onError(["mob" => " *Enter the Mobile Number"]);
70
-		}
71
-		elseif (!preg_match("/^[0-9]{10}$/", $mob)) {
67
+		} elseif (!preg_match("/^[0-9]{10}$/", $mob)) {
72 68
 			$this->onError(["mob" => " *Enter correct Mobile Number"]);
73 69
 		}
74 70
 
75 71
 		if($this->key == 1)
76 72
 		{
77 73
 			return json_encode($this->error);
78
-		}
79
-		else
74
+		} else
80 75
 		{
81 76
 			$this->key = 0;
82 77
 			$pass = md5($password);
@@ -84,8 +79,7 @@  discard block
 block discarded – undo
84 79
 			if(!$this->connect->query($query)) {
85 80
 				$this->key = 1;
86 81
 				echo "You are not registered || Error in registration1";
87
-			}
88
-			else
82
+			} else
89 83
 			{
90 84
 				$query = "SELECT id FROM register WHERE email = '$email'";
91 85
 				if($result = $this->connect->query($query)) {
@@ -96,8 +90,7 @@  discard block
 block discarded – undo
96 90
 					if(!$this->connect->query($query)) {
97 91
 						$this->key = 1;
98 92
 						echo "You are not registered || Error in registration2";
99
-					}
100
-					else
93
+					} else
101 94
 					{
102 95
 						$query = "INSERT INTO profile VALUES('$userId', 'Joined OpenChat', 'Joined OpenChat', '')";
103 96
 						if(!$this->connect->query($query)) {
@@ -113,8 +106,7 @@  discard block
 block discarded – undo
113 106
 			return json_encode([
114 107
 				"location" => URL."/account.php"
115 108
 			]);
116
-		}
117
-		else
109
+		} else
118 110
 		{
119 111
 			return json_encode($this->error);
120 112
 		}
Please login to merge, or discard this patch.