Guest User

Untitled

a guest
Jul 8th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. $sql = "SELECT * FROM user WHERE username = '$username' and password='$epassword'";
  2. $result = mysqli_query($con,$sql);
  3.  
  4. $row = mysqli_fetch_array($result,MYSQLI_ASSOC);
  5.  
  6. $active = $row['active'];
  7.  
  8. $count = mysqli_num_rows($result);
  9. // If result matched myusername and mypassword, table row must be 1 row
  10.  
  11. if($count >0) {
  12.  
  13. //$response = "Your Login success";
  14. $response = return ['operation' => 'Your Login success', 'data' => $row];
  15.  
  16. }else {
  17.  
  18. $response= "Your Login Email or Password is invalid";
  19.  
  20. }
  21.  
  22. signIn(){
  23.  
  24. //// check to confirm the username and password fields are filled
  25.  
  26. if(this.username.value=="" ){
  27.  
  28. let alert = this.alertCtrl.create({
  29.  
  30. title:"ATTENTION",
  31.  
  32. subTitle:"Username field is empty",
  33.  
  34. buttons: ['OK']
  35.  
  36. });
  37.  
  38. alert.present();
  39.  
  40. } else
  41.  
  42. if(this.password.value==""){
  43.  
  44. let alert = this.alertCtrl.create({
  45.  
  46. title:"ATTENTION",
  47.  
  48. subTitle:"Password field is empty",
  49.  
  50. buttons: ['OK']
  51.  
  52. });
  53.  
  54. alert.present();
  55.  
  56. }
  57.  
  58. else
  59.  
  60. {
  61.  
  62. var headers = new Headers();
  63.  
  64. headers.append("Accept", 'application/json');
  65.  
  66. headers.append('Content-Type', 'application/json' );
  67.  
  68. let options = new RequestOptions({ headers: headers });
  69.  
  70. let data = {
  71.  
  72. username: this.username.value,
  73.  
  74. password: this.password.value
  75.  
  76. };
  77.  
  78. let loader = this.loading.create({
  79.  
  80. content: 'Processing, please wait…',
  81.  
  82. });
  83.  
  84. loader.present().then(() => {
  85.  
  86. //this.http.post('http://localhost:90/totallight/api/login.php',data,options)
  87.  
  88. this.http.post('http://edomonitor.com/school-evaluation-api/login.php',data,options)
  89.  
  90. .map(res => res.json())
  91.  
  92. .subscribe(res => {
  93. ///resolve(res.json())
  94. //.then(res => res.json())
  95. //.then(json => console.log(json))
  96.  
  97. console.log(data)
  98.  
  99. loader.dismiss()
  100.  
  101. if(res=="Your Login success"){
  102.  
  103.  
  104.  
  105. //this.authService.setToken(data.token, data.id, data.name, data.email);
  106.  
  107. /*let alert = this.alertCtrl.create({
  108.  
  109. title:"CONGRATS",
  110.  
  111. subTitle:(res),
  112.  
  113. buttons: ['OK']
  114.  
  115. });
  116.  
  117. alert.present();*/
  118. }else
  119.  
  120. {
  121.  
  122. let alert = this.alertCtrl.create({
  123.  
  124. title:"ERROR",
  125.  
  126. subTitle:"Invalid username/password",
  127.  
  128. buttons: ['OK']
  129.  
  130. });
  131.  
  132. alert.present();
  133.  
  134. }
  135.  
  136. });
  137.  
  138. });
  139.  
  140. }
  141.  
  142. }
Add Comment
Please, Sign In to add comment