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

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

declare(strict_types=1);

noplanman's avatar
noplanman committed
9 10
use RedBeanPHP\R;

11
// Required parameters.
12 13
($_username = $_POST['username'] ?? null) || die('Name is required');
//($_userurl = $_POST['userurl'] ?? null) || die('no userurl given');//lets not annoy people on this for now
14
($_domain = $_POST['domain'] ?? null) || die('no pod domain given');
15
($_comment = $_POST['comment'] ?? null) || die('A comment is required');
dmorley's avatar
dmorley committed
16
($_rating = $_POST['rating'] ?? null) || die('A rating is required');
17

18
require_once __DIR__ . '/../boot.php';
noplanman's avatar
noplanman committed
19 20

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

32
print 1;