Advertisement
Guest User

Untitled

a guest
Jul 15th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. sign-in.component.ts
  2.  
  3. login()
  4. {
  5. console.log(this.username+this.password)
  6.  
  7. this.dataService.authenticate(this.username, this.password)
  8. .subscribe(
  9. (result) => {
  10. this.profile = result.data;
  11. console.log(result);
  12. }
  13.  
  14. )
  15.  
  16. }
  17. data-service.ts
  18. authenticate(username: string, password: string)
  19. {
  20. let headers = new Headers();
  21. //headers.append('Content-Type', 'application/json');
  22. headers.append('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
  23. var data = { username: username, password: password }
  24. //console.log(data);
  25. //console.log(JSON.stringify(data));
  26. return this.http.post('http://localhost/api/select.php/',JSON.stringify(data),headers).map(res => res.json());
  27.  
  28.  
  29. }
  30.  
  31. select.php
  32. <?hphp
  33. $postdata = file_get_contents("php://input");
  34. $request = json_decode($postdata);
  35. $username = $request->username;
  36. $password = $request->password;
  37.  
  38.  
  39. echo "$username"
  40. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement