security.php
class Security {
public function sanitize($data) {
return mysql_real_escape_string($data);
}
}
?>
users.php
<?php
class User {
private $db;
public function __construct() {
$this->db = new Connection();
$this->db = $this->db->dbConnect();
}
public function userExists($username) {
$username = sanitize($username);
$st = $this->db->prepare("SELECT * FROM `users` WHERE `username`=? ");
$st->bindParam(1, $username);
$st->execute();
if ($st->rowCount() == 1) {
echo "User exists";
} else {
echo 'Incorrect username or password lad';
}
}
}
?>
in my user exists method i want to use sanitize method but im am unsure the correct way to do this in oop. both class are on a different file. any help appreciated.