Advertisement
Guest User

Untitled

a guest
Oct 7th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. $Username= filter_var($_REQUEST['Username'], FILTER_SANITIZE_STRING, FILTER_FLAG_ENCODE_LOW);
  2. $Password = filter_var($_REQUEST['Password'], FILTER_SANITIZE_STRING, FILTER_FLAG_ENCODE_LOW);
  3. $sql="SELECT Username, Password FROM doctoradd WHERE Username = :Username AND Password = :Password";
  4. //$sql = "INSERT INTO technologies(name, description) VALUES(:Username, :Password)";
  5. $stmt = $pdo->prepare($sql);
  6. $stmt->bindParam(':Username', $Username, PDO::PARAM_STR);
  7. $stmt->bindParam(':Password', $Password, PDO::PARAM_STR);
  8. $stmt->execute();
  9. while($row = $stmt->fetch(PDO::FETCH_OBJ))
  10. {
  11. // Assign each row of data to associative array
  12. $data[] = $row;
  13. }
  14. if($data == []){
  15. echo json_encode("null");
  16. }
  17. else{
  18. echo json_encode("accepted");
  19.  
  20. }
  21.  
  22. let Username : string = this.form.controls["Username"].value,
  23. Password : string = this.form.controls["Password"].value;
  24.  
  25. let body : string = "Username=" + Username + "&Password=" + Password,
  26. type : string = "application/x-www-form-urlencoded; charset=UTF-8",
  27. headers : any = new Headers({ 'Content-Type': type}),
  28. options : any = new RequestOptions({ headers: headers }),
  29. url : any = this.baseURI + "sign-in.php";
  30.  
  31. this.http.post(url, body, options)
  32. .subscribe((data) =>
  33. {
  34. // If the request was successful notify the user
  35. // if(data.status === 200)
  36. // {
  37. // //this.hideForm = true;
  38.  
  39. // this.toast.create({
  40. // message: 'Welcome ',
  41. // duration:3000
  42.  
  43.  
  44. // }).present();
  45. // //this.sendNotification(`Congratulations the technology: ${username} was successfully added`);
  46.  
  47.  
  48.  
  49. // }
  50. // // Otherwise let 'em know anyway
  51. // else
  52. // {
  53. // //this.sendNotification('Something went wrong!');
  54. // this.toast.create({
  55. // message: 'Wrong Username or Password',
  56. // duration:3000
  57.  
  58.  
  59. // }).present();
  60.  
  61. // }
  62.  
  63.  
  64.  
  65. });
  66.  
  67.  
  68. this.SignIn();
  69.  
  70. SignIn(){
  71. this.http.get('http://localhost:10080/testdb/sign-in.php')
  72. .map(res => res.json())
  73. .subscribe(data =>
  74. {
  75. this.items = data;
  76. });
  77. alert(this.items);
  78. if(this.items=="accepted"){
  79. this.navCtrl.push('ExamplePage',this.username);
  80. }
  81. else{
  82. this.toast.create({
  83. message: 'Wrong Username or Password',
  84. duration:3000
  85. }).present();
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement