Guest User

Untitled

a guest
Apr 6th, 2018
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. [{"username":"User1","password":"Password"},
  2. {"username":"User5","password":"passWord"},]
  3.  
  4. <?php $username = $_POST["username"]; ?><br>
  5. <?php $password = $_POST["password"]; ?><br>
  6.  
  7. <?php
  8.  
  9. $currentData = file_get_contents('UserJSON.txt');
  10. $array_data = json_decode($currentData, true);
  11. $extra = array(
  12. 'username' => $username,
  13. 'password' => $password
  14. );
  15. $array_data[] = $extra;
  16. $final_data = json_encode($array_data);
  17. if(file_put_contents('UserJSON.txt',$final_data)) {
  18. print("working");
  19. }
  20.  
  21. ?>
  22.  
  23. <?php
  24. $urlText = $_REQUEST["urlText"];
  25. $currentData = file_get_contents('UserJSON.txt');
  26. $array_data = json_decode($currentData, true);
  27. //for loop
  28. $array_data[i]['Posts'] = $urlText;
  29. //end for loop
  30. $final_data = json_encode($array_data);
  31. if(file_put_contents('UserJSON.txt',$final_data)) {
  32. }
  33. ?>
  34.  
  35. [{"username":"User1","password":"Password","Posts:{"This is a post"}},
  36. {"username":"User5","password":"passWord"},"Posts:{"This is a post2"}}]
Add Comment
Please, Sign In to add comment