Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- session_start();
- header('Access-Control-Allow-Origin: *');
- header('Access-Control-Allow-Methods: PUT, GET, POST, DELETE, OPTIONS');
- header('Access-Control-Allow-Headers: Content-Type');
- $postdata = file_get_contents("php://input");
- if(isset($postdata) && !empty($postdata)) {
- $request = json_decode($postdata);
- $username=trim($request->username);
- $password=trim($request->password);
- if($username == 'admin' && $password == 'admin') {
- $_SESSION['user'] = 'admin';
- ?>
- {
- "success": true,
- "secret": "This is the secret no one knows but the admin"
- }
- <?php
- } else {
- ?>
- {
- "success": false,
- "message": "Invalid credentials"
- }
- <?php
- }
- } else {
- //var_dump($_POST)
- ?>
- {
- "success": false,
- "message": "Only POST access accepted"
- }
- <?php
- }
- ?>
- <?php
- session_start();
- header('Access-Control-Allow-Origin: *');
- header('Access-Control-Allow-Methods: PUT, GET, POST, DELETE, OPTIONS');
- header('Access-Control-Allow-Headers: Content-Type');
- $user = $_SESSION['user'];
- echo '{
- "message": "'.$user.'",
- "success": true
- }';
- ?>
- ngOnInit() {
- this.auth.getUserDetails('admin','admin')
- .subscribe(
- data => {
- console.log('success',data);
- if(data.success){
- }
- else{
- window.alert("invalid");
- }
- },
- error=> {
- console.log('failed',error);
- }
- )
- var _this=this;
- setTimeout(function(){
- _this.user.getSomeData().subscribe(data=>{
- console.log(data);
- })
- }, 3000);
- }
Add Comment
Please, Sign In to add comment