I
I
Insom842021-06-10 09:15:18
1C-Bitrix
Insom84, 2021-06-10 09:15:18

How to display the number of successful Bitrix form submissions?

There is a submission form, it has an input of the number of projects, now it displays an increasing number when the page is updated, with this script:

<?php
session_start();

$nom = isset($_SESSION["nom"]) ? intval($_SESSION["nom"] + 1) : 1;
$_SESSION["nom"] = $nom = $nom > 999 ? 999 : $nom;

echo $nom < 10 ? "00".$nom : ($nom < 100 ? "0".$nom : $nom);
?>

And I would like it to display the number of successful form submissions. Please tell me the code for such an implementation (not strong in php)
Here is an excerpt from the form:
<form id="deal_form_lk" class="sform" action="javascript:void(null);" onsubmit="send_form_lk('deal_form_lk')">
  <div class="input-group col-12 col-md-6">
                   <input id="nomerForm"  type="text" name="nomerForm" placeholder="" class="form-control" value="№ проекта: <?=substr("00".$nom, -3);?>" readonly/>
        </div>
<button id="deal_btn" type="submit"  class="modal_btn round-btn-style btn-style">Отправить</button>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Insom84, 2021-06-11
@Insom84

As I understand it, it is possible to write a number to a file like this code, but I can’t integrate it in any way:
or am I mistaken?

if (isset($_POST['submit'])) {
    
    if (!file_exists('count.txt')) {
        $cnt = 1;
        $f = fopen('count.txt', 'w+');
        fwrite($f, $cnt);
        fclose($f);
    } else {
        $f = fopen('count.txt', 'r');
        $cnt = (int) fgets($f);
        fclose($f);
        $cnt++;
        $f = fopen('count.txt', 'w+');
        fwrite($f, $cnt);
        fclose($f);
    }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question