Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require 'vendor/autoload.php';
- use Ramsey\Uuid\Uuid;
- use Ramsey\Uuid\Exception\UnsatisfiedDependencyException;
- if ($_SERVER['REQUEST_METHOD'] === 'POST') {//Czy wszedlem poste
- if (isset($_POST['login']) && isset($_POST['mail']) && isset($_POST['userDescription'])) {//Czy wyslalem wszystkie dne
- if (!isset($_COOKIE['uuid'])) { //CZy jest ciastko UUID
- try {//Funkcja ktora łapie błędy
- $uuid1 = Uuid::uuid1(); //Generuje uuid
- $uuidId = $uuid1->toString();
- setcookie('uuid', $uuidId, time() + 3600 * 6); //ustawiamy ciastko z tym ID
- } catch (UnsatisfiedDependencyException $e) {
- echo 'Caught exception: ' . $e->getMessage() . "\n"; //Jeżeli był błąd to pokazujemy dane o nim
- }
- } else {
- $uuidId = $_COOKIE['uuid']; //Pobieramy uuid ciastka
- }
- echo 'UUID: ' . $uuidId;
- }
- }
- ?>
- <!doctype html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport"
- content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
- <meta http-equiv="X-UA-Compatible" content="ie=edge">
- <title>Zadanie 1</title>
- </head>
- <body>
- <form method="post" action="index.php">
- <input name="login">
- <input name="mail">
- <textarea name="userDescription"></textarea>
- <input type="submit">
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement