How to create login page using ionic?


#1

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.



#2

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


#3

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


#4

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.


#5

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


#6

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


#7

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