Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class LoginAction implements IAction
- {
- public function __construct ()
- {
- }
- private function exists($username, $password)
- {
- $connection = new mysqli('localhost', 'root', '', 'tema3');
- $query = "SELECT * from users";
- $result = $connection->query($query);
- $ok = 0;
- while ($row = $result->fetch_assoc() )
- {
- print_r($row);
- if ($row['password'] == md5($password) && $row['username'] == $username)
- {
- $ok = 1;
- break;
- }
- }
- if ($ok == 1)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- public function actionIsset ()
- {
- if (!isset($_POST))
- {
- return false;
- }
- $user = $_POST["username"];
- $pass = $_POST["password"];
- if (empty($user) || empty($pass))
- {
- return false;
- }
- return($this->exists($user, $password));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement