Reputation: 401
I have created a very simple ionic application with a login and username so far. I am currently using Microsoft azure mobile services to host my application. However I don't know how to work with a php file and a server. I am a beginner with working with servers thank you in advance.
PHP Code:
<?php
try {
$conn = new PDO("microsoft azure connection string", "username", "password");
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch (PDOException $e) {
print("Error connecting to SQL Server.");
die(print_r($e));
}
?>
login controller :
.controller('loginCtrl', ['$scope', '$stateParams', // The following is the constructor function for this page's controller. See https://docs.angularjs.org/guide/controller
// You can include any angular dependencies as parameters for this function
// TIP: Access Route Parameters for your page via $stateParams.parameterName
function ($scope, $stateParams) {
$scope.User = {};
$scope.login = function() {
str="Dont know what to put here";
$http.get(str)
.success(function (response){
}).error(function() { //if login failed
var alertPopup = $ionicPopup.alert({
title: 'Login failed!',
template: 'Please check your credentials!'
});
});
};
}])
login html
<ion-view title="Login" id="page6">
<ion-content padding="true" class="has-header">
<form id="login-form4" class="list">
<ion-list id="login-list2">
<label class="item item-input" id="login-input10">
<span class="input-label">Username/Email</span>
<input type="text" ng-model="User.email" placeholder="">
</label>
<label class="item item-input" id="login-input11">
<span class="input-label">Password</span>
<input type="password" ng-model="User.password" placeholder="">
</label>
</ion-list>
<div class="spacer" style="height: 40px;"></div>
<a id="login-button2" ng-click="login()" class="button button-positive button-block">Log in</a>
<a ui-sref="signup" id="login-button3" class="button button-positive button-block button-clear">Or create an account</a>
</form>
</ion-content>
</ion-view>
Upvotes: 0
Views: 530
Reputation: 9940
Currently, the Azure App Service Mobile Apps SDK is provided for ASP.NET and Node.js web applications. So, you could switch your backend to Node.js or .NET backend instead.
Then you can create Easy API
/Custom API
in your mobile backend, and you are able to connect your API with invokeApi() of Javascript Clients for Azure Mobile Apps.
For more information, please refer to this blog post.
Upvotes: 1