How to create login page using ionic?

Hi,

I am new to Ionic framework and I am currently working on login page using Ionic framework with using MySQL database and return the data from it as JSON using PHP.

But when I run the code, the $http does not send the values and it throws the error.

image


Look no further than Andrew McGivery blog article: http://mcgivery.com/100-ionic-framework-resources/

Look for the chapter: Authentication, there you’ll find 6 distinct tutorials

1 Like

Hi,

In that site, they didn’t gave the example for login and validating the username and password from the mysql db.

this is my controller

$scope.selva = function(loginData) {

$http.post(’"http://adhiyamaanit.in/Selvaraj/login.php?username=loginData.username&password=loginData.password’)
.success(function(data) {
alert(data)
var alertPopup = $ionicPopup.alert({
title: ‘Success’,
template: ‘You are ON’
});
alertPopup.then(function(res) {

});
// $scope.state.go(‘home’);
})

when i enter the url http://adhiyamaanit.in/Selvaraj/login.php?username=username&password=password it return the message correctly but when i enter into the controller.js as above, it throws the exception.

Thanks in advance
Selvaraj C

Your’re using a POST method and you pass parameters in query string (as in a GET), I don’t know how you PHP code works but it’s not consistent anyway.

1 Like

Hi,

Thanks for the reply.

Could you provide the sample code on how to pass the data when we are using post method?

Regards
Selvaraj C

Search in the forum, a member just posted a link to a blog using $http or $resource or read angular docs.

Other things you should consider is to read about CORS and use https for your server.