Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. <?php
  2. $name = $_POST['name'];
  3. $email = $_POST['email'];
  4. $date = $_POST['date'];
  5. $destination = $_POST['destination'];
  6. $msg = $_POST['msg'];
  7.  
  8. //TODO the file write here VV, use 'a' instead of 'w' too ADD to the file instead of REWRITING IT.
  9. $arr = [$name,$email,$date,$destination,$msg];
  10.  
  11. $write = json_encode($arr);
  12. echo $write;
  13.  
  14. $file = fopen('data.txt', 'a');
  15. fwrite($file, $write);
  16. fclose($file);
  17. // echo $arr[];
  18. ?>
  19.  
  20. ["Simon","example@example.com","0101-01-01T01:01","Ohio","Message here"][null,null,null,null,null]
  21.  
  22. <?php
  23. if (isset($_POST['name'])
  24. && isset($_POST['email'])
  25. && isset($_POST['date'])
  26. && isset($_POST['destination'])
  27. && isset($_POST['msg'])) {
  28. $name = $_POST['name'];
  29. $email = $_POST['email'];
  30. $date = $_POST['date'];
  31. $destination = $_POST['destination'];
  32. $msg = $_POST['msg'];
  33.  
  34. //TODO the file write here VV, use 'a' instead of 'w' too ADD to the file instead of REWRITING IT.
  35. $arr = [$name,$email,$date,$destination,$msg];
  36.  
  37. $write = json_encode($arr);
  38. var_dump( $write);
  39. $file = fopen('data.txt', 'a');
  40. fwrite($file, $write);
  41. fclose($file);
  42. // echo $arr[];
  43. }
  44. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement