saverating.php 735 Bytes
Newer Older
root's avatar
root committed
1
<?php
2

3 4 5 6 7 8
/**
 * Save pod rating.
 */

declare(strict_types=1);

9 10
use RedBeanPHP\R;

11
// Required parameters.
12
($_username = $_POST['username'] ?? null) || die('Name is required');
13
($_domain = $_POST['domain'] ?? null) || die('no pod domain given');
14
($_comment = $_POST['comment'] ?? null) || die('A comment is required');
15
($_rating = $_POST['rating'] ?? null) || die('A rating is required');
16

17
require_once __DIR__ . '/../boot.php';
18 19

try {
20 21 22 23 24 25
    $r             = R::dispense('ratingcomments');
    $r['domain']   = $_domain;
    $r['comment']  = $_comment;
    $r['rating']   = $_rating;
    $r['username'] = $_username;
    R::store($r);
26
} catch (\RedBeanPHP\RedException $e) {
27
    die('Error in SQL query: ' . $e->getMessage());
28
}
29

30
print 1;