A
A
Anton Plawkevich2020-05-26 16:06:43
PHP
Anton Plawkevich, 2020-05-26 16:06:43

json file iteration?

Good afternoon, when submitting the form, I try to pull the files into json , json itself is created, but when resending a new file is not created, for example, a person sends the form 1.json is created, sends the next one and 2.json is created accordingly.

<?php
$post = (!empty($_POST)) ? true : false;
if($post) {
  $name = $_POST['name'];
  $phone = $_POST['phone'];
  $viber = $_POST['viber'];
  $whatsapp = $_POST['whatsapp'];
  $telegram = $_POST['telegram'];
  $tel = $_POST['tel'];
  $date = date_create();
  $filename = "" . strval(count(glob('./json')) + 1) . ".json";
  $insertvote = [
      'Имя: ' => $name,
      'Телефон: ' => $phone ];
  $pretty = json_encode($insertvote, JSON_UNESCAPED_UNICODE);
  $fp = fopen($filename,"w");
  fputs($fp,$pretty);
  fclose($fp);
  $error = ''; ?>


I will be grateful for advice

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Shamanov, 2020-05-27
@SilenceOfWinter

How could this possibly work?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question