Exemplo n.º 1
0
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <input type="submit" value="Submit"/>
                                    </td>
                                </tr>
                            </table>     
                    </td>
                </tr>
                <tr>
                    <td>
                        <img class="social_img" src="http://www.fionaarmstrong.com.au/wp-content/uploads/Facebook.png" alt="facebook">
                        <img class="social_img" src="http://www.houstondentalesthetics.com/images/twitter_thumb(1).png" alt="twitter">
                        <img class="social_img"  src="https://perishablepress.com/wp/wp-content/images/2006/feed-collection/feed-icon_orange-64px.png" alt="RSS feed">
                </tr>
            </table>

            <?php 
if (empty($_POST['user'])) {
    return false;
} else {
    $a = $_POST['user'];
}
if (empty($_POST['comment'])) {
    return false;
} else {
    $b = $_POST['comment'];
}
post_feedback($a, $b);
Exemplo n.º 2
0
<?php

session_start();
require 'database.php';
switch ($_SERVER["REQUEST_METHOD"]) {
    case 'GET':
        get_feedback();
        break;
    case 'POST':
        post_feedback();
        break;
    default:
        http_response_code(405);
        die;
}
function get_feedback()
{
    if ($_SESSION["loggedin"] == true) {
        $db = new Database();
        $sth = $db->prepare('SELECT * FROM feedback');
        $sth->execute();
        echo json_encode($sth->fetchAll(PDO::FETCH_ASSOC));
    } else {
        echo json_encode(array('status' => 'unauthorized'));
        http_response_code(403);
    }
}
function post_feedback()
{
    $data = json_decode(file_get_contents('php://input'));
    $db = new Database();