Can't fetch MySql Database using pHp for simple login page

As i am new to fusetools i found it usefull, but when i started to make a simple login page for my app, I dont know what i am doing wrong your help will be appreciated. below is javascript code which i get from your forum

var Observable = require("FuseJS/Observable");
var errmsg = Observable("");
var username = Observable("");
        var password = Observable("");

        var uri = ""
        var sendRequest = function() {
            var options = {
                method: 'POST',
                headers: {
                    'Accept': 'application/json',
                    'Content-Type': 'application/json',
                    'Authorization': 'Basic ' + btoa(username.value + ':' + password.value)
                body: JSON.stringify({
                    username: username.value,
                    password: password.value,
            fetch(uri, options).then(function(response) {
                var data = JSON.stringify(response)
            }, function(error) {
                errmsg = "Error Occured";

        module.exports = {
            username: username, 
            password: password,
            send: sendRequest,

    module.exports = {
    items: items
    username: username
    password: password
    loggingin : sendRequest
    failedlogin: errmsg

and this are the textinputs of my .ux file

<TextInput  Row="0" Column="1" PlaceholderText="Username" Value="{username}" PlaceholderColor="#999" TextColor="#fff" />
<TextInput  Row="1" Column="1" PlaceholderText="Password" Value="{password}" PlaceholderColor="#999" TextColor="#fff" />

and this will generate click event after user enter valid login credentials

<Text ux:Name="text" Alignment="Center" Value="Sign in" FontSize="18" TextColor="#fff"/>

and following below is the php files which returns json format data


require_once 'include/DB_Functions.php';
$db = new DB_Functions();

// json response array
$response = array("error" => FALSE);

if (isset($_POST['username']) && isset($_POST['password'])) {

    // receiving the post params
    $username = $_POST['username'];
    $password = $_POST['password'];

    // get the user by email and password
    $user = $db->getUserByUsernameAndPassword($username, $password);

    if ($user != false) {echo json_encode($response);
    } else {
        // user is not found with the credentials
        $response["error"] = TRUE;
        $response["error_msg"] = "Login credentials are wrong. Please try again!";
        echo json_encode($response);
} else {
    // required post params is missing
    $response["error"] = TRUE;
    $response["error_msg"] = "Required parameters email or password is missing!";
    echo json_encode($response);

and Php Login Function ``` class DB_Functions {

private $conn;

// constructor
function __construct() {
    require_once 'DB_Connect.php';
    // connecting to database
    $db = new Db_Connect();
    $this->conn = $db->connect();
public function getUserByUsernameAndPassword($username, $password) {
    $stmt = $this->conn->prepare("SELECT * FROM Users WHERE Username = ?");

    $stmt->bind_param("s", $username);

    if ($stmt->execute()) {
        $user = $stmt->get_result()->fetch_assoc();

        // verifying user password
        //$salt = $user['salt'];
    $encrypted_password = md5($password);
        $encrypted_password1 = $user['Password'];
        //$hash = $this->checkhashSSHA($salt, $password);
        // check for password equality
        if ($encrypted_password1 == $encrypted_password) {
            // user authentication details are correct
            return $user;
    } else {
        return NULL;


?> As Obvoius database connection and url is working fine but i am having problem in fuse only as the php side script is clear which returns data in normal nonfuse application login is working fine but i want to learn fuse and how its handling fetch function i have gone through all the forums regarding mysql.

Hi! :slight_smile: I have some trouble understand exactly what you are asking about. Can you please clarify what is not working as expected? (What should happen, and what happens instead?)

The server-side part, whether through php & mysql or other solutions, is unrelated to Fuse and therefore not anything we can provide any help on. As long as the server exposes a REST API that the Fuse app can use through HTTP requests performed with fetch() everything should be ok on that side.

In this repo you can also find some examples of different logins: (Specifically the Oauth(github), Facebook login and Amazon S3 examples)