Guest User

demo.php

a guest
Apr 12th, 2017
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.59 KB | None | 0 0
  1. <?php
  2.     function fetchData()
  3.     {
  4.         $inputText = file_get_contents("php://input");
  5.         $userInputs = explode("&", $inputText);
  6.  
  7.         $data = array();
  8.  
  9.         foreach ($userInputs as $input) {
  10.             $keyValue = explode("=", $input);
  11.             $key = $keyValue[0];
  12.             $value = $keyValue[1];
  13.  
  14.             $data[$key] = $value;
  15.         }
  16.  
  17.         return $data;
  18.     }
  19.  
  20.     $data = fetchData();
  21.  
  22.     $username = $data['username'];
  23.     $password = $data['password'];
  24.  
  25.     header('Content-Type: application/json');
  26.     echo json_encode($data);
  27.  ?>
Add Comment
Please, Sign In to add comment