php - Ionic Framework - Check Email Availability From MySQL Database Using Ajax -


checking email address availability of user on ng-keyup via ajax using mysql db. i'm not able figure out error. please go through code below. have added function checkemail() controller don't know correct way call functions in controller.

html

<label class="item item-input item-stacked-label"> <span class="input-label">email</span> <input type="text" id="email" name="email" ng-keyup="checkemail()" placeholder="email" ng-model="data.email"> <span id="email_status"></span> 

app.js

angular.module('starter.controllers', []).controller('registrationctrl', function ($scope, $http) {      function checkemail() {          var email = document.getelementbyid("email").value;         if (email) {             $.ajax({                 type: 'post',                 url: 'http://proittechnology.com/dev/stylr/checkemail.php',                 data: {                     email: email,                 },                 success: function (response) {                     $('#email_status').html(response);                     if (response == "ok") {                         return true;                     } else {                         return false;                     }                 }             });           } else {             $('#email_status').html("");             return false;         }      }     $scope.data = {};      $scope.submit = function () {         var link = 'http://proittechnology.com/dev/stylr/createaccount.php';          $http.post(link, { firstname: $scope.data.firstname, lastname: $scope.data.lastname, email: $scope.data.email, password: $scope.data.password }).then(function (res) {             $scope.response = res.data;             alert('your account has been created successfully');         });     }; }) 

checkemail.php

if(isset($_post['email'])) {  $email=$_post['email'];   $checkdata=" select email users email='$email' ";   $query=mysqli_query($db, $checkdata);   if(mysqli_num_rows($query)>0)  {  echo mysqli_num_rows($query)['email'];   echo "email exist";  }  else  {   echo "ok";  }  exit(); } 


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -