<?php
class test_class {
public function __construct() {
}
public function doLogin($username,$password) {
include("connection.php");
$query = "SELECT *
FROM users
WHERE username = '".mysql_escape_string($username)."'
AND password = '".mysql_escape_string($password)."'";
$result = mysql_fetch_array(mysql_query($query));
if(!$result) {
return 'no';
}
else
{
return 'yes';
}
}
}
?>
The above code works, but slightly worried whether its secure or not.
Note: I am not using POST method, so i have to receive it as arguments in the function and i cannot use.
if (isset($_POST['username']) && isset($_POST['password']))
{
$username= $_POST['username'];
$password= $_POST['password'];