Random number identification in PHP and JSON

Asked

Viewed 47 times

0

I am creating a chat in PHP and JSON. I have an algorithm that generates a random number that turns into a file . json.

I then want to identify the Random number that was generated by PHP, it is possible.

    <?php

    $rand = rand(1, 100);

$jsonword = ".json"; $file = 'json/'.$rand.$jsonword; if(isset($_POST["submit"])) {
    $encr = json_encode($_POST, JSON_PRETTY_PRINT);
    echo file_put_contents($file, $encr, FILE_APPEND);
    header('Location: index.php'); } $i = file_get_contents(/*Preciso de ajuda aqui :( */); $a = json_decode($i); ?> <!DOCTYPE html> <head> <title><?php echo $a->mensagem; ?></title> <meta charset="UTF-8"> <body> <form method="post"> <input type="text" name="mensagem" id="mensagem" placeholder="mensagem..."> <input type="submit" name="submit" id="submit" value="Enviar"> </form> </body> </head>
  • From what I understand you want to recover this randomly generated number? this would be possible through a return of a variable, using - a to save in the bank or in the file to stay permanently or use it within the scope not to lose.

  • how can I make this return?

  • You save this value in the $Rand variable, retrieve it or save it in a comic, using it before finishing

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.