Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sign-in.component.ts
- login()
- {
- console.log(this.username+this.password)
- this.dataService.authenticate(this.username, this.password)
- .subscribe(
- (result) => {
- this.profile = result.data;
- console.log(result);
- }
- )
- }
- data-service.ts
- authenticate(username: string, password: string)
- {
- let headers = new Headers();
- //headers.append('Content-Type', 'application/json');
- headers.append('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
- var data = { username: username, password: password }
- //console.log(data);
- //console.log(JSON.stringify(data));
- return this.http.post('http://localhost/api/select.php/',JSON.stringify(data),headers).map(res => res.json());
- }
- select.php
- <?hphp
- $postdata = file_get_contents("php://input");
- $request = json_decode($postdata);
- $username = $request->username;
- $password = $request->password;
- echo "$username"
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement