@@ -12,26 +12,26 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | |
@@ -20,19 +20,19 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -131,6 +131,6 @@ |
||
| 131 | 131 | <?php |
| 132 | 132 | } |
| 133 | 133 | else{ |
| 134 | - header('Location:http://localhost/openchat'); |
|
| 134 | + header('Location:http://localhost/openchat'); |
|
| 135 | 135 | } |
| 136 | 136 | ?> |
@@ -7,85 +7,85 @@ |
||
| 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 | } |
@@ -30,8 +30,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -7,116 +7,116 @@ |
||
| 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 | } |
@@ -38,11 +38,9 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -4,35 +4,35 @@ |
||
| 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 | } |
@@ -14,12 +14,13 @@ |
||
| 14 | 14 | $connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); |
| 15 | 15 | $query = "SELECT * from profile where login_id = '$userId'"; |
| 16 | 16 | $result = $connect->query($query); |
| 17 | - if($result->num_rows > 0) // if true |
|
| 17 | + if($result->num_rows > 0) { |
|
| 18 | + // if true |
|
| 18 | 19 | { |
| 19 | 20 | $details = $result->fetch_assoc(); |
| 20 | - return $details; |
|
| 21 | 21 | } |
| 22 | - else |
|
| 22 | + return $details; |
|
| 23 | + } else |
|
| 23 | 24 | { |
| 24 | 25 | return NULL; |
| 25 | 26 | } |
@@ -5,13 +5,13 @@ |
||
| 5 | 5 | |
| 6 | 6 | if(isset($_POST['q'])) |
| 7 | 7 | { |
| 8 | - $loginField = json_decode($_POST['q']); |
|
| 9 | - $login = $loginField->login; |
|
| 10 | - $password = $loginField->password; |
|
| 11 | - $obLogin = new Login(); |
|
| 12 | - $result = $obLogin->authLogin($login, $password); |
|
| 13 | - if(isset($result)) |
|
| 14 | - echo $result; |
|
| 15 | - else |
|
| 16 | - echo json_encode([]); |
|
| 8 | + $loginField = json_decode($_POST['q']); |
|
| 9 | + $login = $loginField->login; |
|
| 10 | + $password = $loginField->password; |
|
| 11 | + $obLogin = new Login(); |
|
| 12 | + $result = $obLogin->authLogin($login, $password); |
|
| 13 | + if(isset($result)) |
|
| 14 | + echo $result; |
|
| 15 | + else |
|
| 16 | + echo json_encode([]); |
|
| 17 | 17 | } |
| 18 | 18 | \ No newline at end of file |
@@ -10,8 +10,9 @@ |
||
| 10 | 10 | $password = $loginField->password; |
| 11 | 11 | $obLogin = new Login(); |
| 12 | 12 | $result = $obLogin->authLogin($login, $password); |
| 13 | - if(isset($result)) |
|
| 14 | - echo $result; |
|
| 15 | - else |
|
| 16 | - echo json_encode([]); |
|
| 17 | -} |
|
| 18 | 13 | \ No newline at end of file |
| 14 | + if(isset($result)) { |
|
| 15 | + echo $result; |
|
| 16 | + } else { |
|
| 17 | + echo json_encode([]); |
|
| 18 | + } |
|
| 19 | + } |
|
| 19 | 20 | \ No newline at end of file |
@@ -5,17 +5,17 @@ |
||
| 5 | 5 | |
| 6 | 6 | if(isset($_POST['q'])) |
| 7 | 7 | { |
| 8 | - $registerField = json_decode($_POST['q']); |
|
| 9 | - $name = $registerField->name; |
|
| 10 | - $email = $registerField->email; |
|
| 11 | - $username = $registerField->username; |
|
| 12 | - $mob = $registerField->mob; |
|
| 13 | - $password = $registerField->password; |
|
| 14 | - $obRegister = new Register(); |
|
| 15 | - $result = $obRegister->authRegister($name, $email, $username, $password, $mob); |
|
| 16 | - if(isset($result)) |
|
| 17 | - echo $result; |
|
| 18 | - else |
|
| 19 | - echo json_encode([]); |
|
| 8 | + $registerField = json_decode($_POST['q']); |
|
| 9 | + $name = $registerField->name; |
|
| 10 | + $email = $registerField->email; |
|
| 11 | + $username = $registerField->username; |
|
| 12 | + $mob = $registerField->mob; |
|
| 13 | + $password = $registerField->password; |
|
| 14 | + $obRegister = new Register(); |
|
| 15 | + $result = $obRegister->authRegister($name, $email, $username, $password, $mob); |
|
| 16 | + if(isset($result)) |
|
| 17 | + echo $result; |
|
| 18 | + else |
|
| 19 | + echo json_encode([]); |
|
| 20 | 20 | } |
| 21 | 21 | |
@@ -13,9 +13,10 @@ |
||
| 13 | 13 | $password = $registerField->password; |
| 14 | 14 | $obRegister = new Register(); |
| 15 | 15 | $result = $obRegister->authRegister($name, $email, $username, $password, $mob); |
| 16 | - if(isset($result)) |
|
| 17 | - echo $result; |
|
| 18 | - else |
|
| 19 | - echo json_encode([]); |
|
| 20 | -} |
|
| 16 | + if(isset($result)) { |
|
| 17 | + echo $result; |
|
| 18 | + } else { |
|
| 19 | + echo json_encode([]); |
|
| 20 | + } |
|
| 21 | + } |
|
| 21 | 22 | |