Login Auth using php web service it's not work


#1

I’m develop my ionic project and i wanna create login auth use .php for mysql database. But i have problem about webservice use .php to connect mydatabase. How controller.js and services.js handle that.
Anyone can help me,please?
this is my login.php on webservice…

<?php error_reporting(E_ALL ^ E_DEPRECATED); $dbhost = "//mydbhost"; $dbuser = "//mydbuser"; $dbpass = "//mydbpass"; $dbname = "//mydbname"; mysql_connect($dbhost,$dbuser,$dbpass); mysql_select_db($dbname); $respon = array(); if (isset($_GET['usernameUser']) && isset($_GET['passwordUser'])) { $usernameUser = $_GET['usernameUser']; $passwordUser = $_GET['passwordUser']; $sql = "SELECT * FROM TBL_PELANGGAN where username='$usernameUser' and password=sha1('$passwordUser')"; if (mysql_num_rows($sql) == 1) { $respon["TBL_PELANGGAN"] = array(); while ($row = mysql_fetch_array($sql)) { // temp member array $user = array(); $user["username"] = $row["username"]; $user["password"] = $row["password"]; array_push($respon["TBL_PELANGGAN"], $user); } $respon["sukses"] = 1; $respon["pesan"] = "Sukses"; echo json_encode($respon); } else { $respon["sukses"] = 0; $respon["pesan"] = "Gagal Login"; echo json_encode($respon); } } else { $respon["sukses"] = 0; $respon["pesan"] = "data belum terset/terisi"; echo json_encode($respon); } ?>

This is my service.js

And this is my controller.js


#2

try changing

$usernameUser = $_GET['usernameUser'];
$passwordUser = $_GET['passwordUser'];

with

$usernameUser = $_POST['usernameUser'];
$passwordUser = $_POST['passwordUser'];

in your PHP.

It’s all because you are using .post query in your js, not .get

It’s about http query’s handling.

read this article for more info