Advertisement
sanjiisan

Untitled

Apr 6th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. <?php
  2. require 'vendor/autoload.php';
  3. use Ramsey\Uuid\Uuid;
  4. use Ramsey\Uuid\Exception\UnsatisfiedDependencyException;
  5.  
  6. if ($_SERVER['REQUEST_METHOD'] === 'POST') {//Czy wszedlem poste
  7. if (isset($_POST['login']) && isset($_POST['mail']) && isset($_POST['userDescription'])) {//Czy wyslalem wszystkie dne
  8. if (!isset($_COOKIE['uuid'])) { //CZy jest ciastko UUID
  9. try {//Funkcja ktora łapie błędy
  10. $uuid1 = Uuid::uuid1(); //Generuje uuid
  11. $uuidId = $uuid1->toString();
  12.  
  13. setcookie('uuid', $uuidId, time() + 3600 * 6); //ustawiamy ciastko z tym ID
  14. } catch (UnsatisfiedDependencyException $e) {
  15. echo 'Caught exception: ' . $e->getMessage() . "\n"; //Jeżeli był błąd to pokazujemy dane o nim
  16. }
  17. } else {
  18. $uuidId = $_COOKIE['uuid']; //Pobieramy uuid ciastka
  19. }
  20.  
  21. echo 'UUID: ' . $uuidId;
  22. }
  23. }
  24.  
  25. ?>
  26. <!doctype html>
  27. <html lang="en">
  28. <head>
  29. <meta charset="UTF-8">
  30. <meta name="viewport"
  31. content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  32. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  33. <title>Zadanie 1</title>
  34. </head>
  35. <body>
  36.  
  37. <form method="post" action="index.php">
  38. <input name="login">
  39. <input name="mail">
  40. <textarea name="userDescription"></textarea>
  41. <input type="submit">
  42. </form>
  43.  
  44. </body>
  45. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement