Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <ion-view title="Login">
- <ion-content overflow-scroll="true" padding="true" class="has-header">
- <?php include '../lib/init.php'; ?>
- <form class="list validate" ng-submit="submit()">
- <input type="hidden" name="action" value="login">
- <ion-list>
- <label class="item item-input">
- <span class="input-label">Username</span>
- <input type="text" ng-model="username" name="username" placeholder="">
- </label>
- <label class="item item-input">
- <span class="input-label">Password</span>
- <input type="password" ng-model="password" name="password" placeholder="">
- </label>
- </ion-list>
- <div class="spacer" style="height: 40px;"></div>
- <button type="submit" id="login-button4" class="button button-royal button-block">Log in</button>
- <a ui-sref="register" id="login-button5" class="button button-royal button-block button-clear">Dont have an account?</a>
- <a ui-sref="forgotPassword" id="login-button6" class="button button-royal button-block button-clear">Forgot password?</a>
- </form>
- </ion-content>
- </ion-view>
- .controller('loginCtrl', function($scope, $state, $stateParams, $ionicPopup, $timeout) {
- //popup alert starts here
- $scope.showAlert = function(status,message) {
- var alertPopup = $ionicPopup.alert({
- title: status,
- template: message,
- });
- };
- //popup alert ends here
- $scope.submit = function() {
- if ($scope.username && $scope.password) {
- var url = 'my PHP file url';
- var username= $scope.username;
- var password= $scope.password;
- $scope.list = [];
- var dataString = 'username='+ username + '&password=' + password;
- $scope.list.push(dataString);
- $scope.text = '';
- $http({
- type: "POST",
- url: url,
- data: dataString,
- success: function(data) {
- try
- {
- alert(data);
- }
- catch(e)
- {
- alert(data);
- }
- }
- });
- }
- };
- })
- .state('login', {
- url: '/login.php',
- templateUrl: 'templates/login.php',
- controller: 'loginCtrl'
- })
- <form class="list validate" ng-submit="submit(username, password)">
- $scope.submit = function(usr, pw) {
- if(!usr || !pw) return;
- //your stuff, not mine
- $scope.list = [];
- var dataString = 'username='+ usr + '&password=' + pw;
- $scope.text = '';
- var payload = {
- username: usr,
- password: pw
- };
- $http.post('path/to/php/file', payload).then(function(response) {
- //success
- alert(response.data);
- }).catch(function(response) {
- //an error occurred
- alert(response.data);
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement