Completed
Push — master ( 35e057...d55c4d )
by Ankit
02:09
created

source/Validate.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
namespace AnkitJain\RegistrationModule;
3
require_once (dirname(__DIR__) . '/config/database.php');
4
5
class Validate
6
{
7
	protected $connect;
8
9
	public function __construct()
10
	{
11
		$this->connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
12
	}
13
14 View Code Duplication
	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
27 View Code Duplication
	function validateUsernameInDb($username)
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
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
}
39