E
E
Egor Chebotarev2016-06-29 21:44:55
PHP
Egor Chebotarev, 2016-06-29 21:44:55

How to count registered users?

There is a makeyourpizza.ru service that registers people for a master class. Static html page with styles and js on apache.
Task: when recording 6 people for a date, close it for recording. From php to YOU ​​and I don’t understand how to implement it.
We need apparently an elementary counter in php, to which js will send information when someone has signed up and read when it will form a calendar with available data.
Post a link or give me a hint.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Egor Chebotarev, 2016-06-30
@Egche

I sat for half a day and wrote the same counter:

$obj = json_decode(file_get_contents('php://input'), true);

    $month = $obj["month"];
    $date = $obj["days"];
    $do = $obj["do"];

    if ($do != "0") {
        foreach ($date as $day) {
            $file = "./order/$month/$day.txt";
            $quantity = file_get_contents($file);

            if ($quantity and ($quantity + 0) < 6) {
                $quantity = $quantity + 1;

                file_put_contents($file, $quantity, LOCK_EX);
            } elseif (!$quantity) {
                file_put_contents($file, 1, LOCK_EX);
            }
        }
    }

It accepts json with the data of the month and day of the recording (plus the do variable, but it was not needed in the end), checks the array of days and looks for the files corresponding to these dates, if it finds it, it takes the content from them and adds 1, if it doesn’t find it, it creates file and writes 1 there.
Well, it checks the group fullness check on the client via ajax

A
Anatoly, 2016-06-29
@taliban

1. you need a database (in any form, maybe even a file)
2. you need a read / write
code 3. you need a code that will communicate with the backend with the frontend
This is not just a script to insert, you need to really understand how it all works to do it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question