Exemplo n.º 1
0
<?php

// handler.php
// handle comment posts, saving to MySQL and redirecting back to the list
if (!isset($_SESSION)) {
    session_start();
}
require_once "classes/dao.php";
if (isset($_SESSION["name"]) && isset($_POST["commentButton"])) {
    $comment = $_POST["comment"];
    $comment_type = $_POST["vote"];
    $bill = $_POST["bill"];
    $username = $_SESSION["name"];
    try {
        $dao = new Dao();
        $dao->saveComment($username, $comment, $bill, $comment_type);
    } catch (Exception $e) {
        var_dump($e);
        die;
    }
} else {
    $dao = new Dao();
    $dao->redirect("../index.php", "Please log in to comment.");
}
header("Location:../index.php");
Exemplo n.º 2
0
<?php

session_start();
require_once $_SERVER['DOCUMENT_ROOT'] . "/resources/Dao.php";
$dao = new Dao();
$user = $dao->getUser($_SESSION["email"]);
$user_id = $user["id"];
$content = clean_input($_POST["content"]);
$post_id = $_POST["post_id"];
$id = $dao->saveComment($user_id, $post_id, $content);
function clean_input($data)
{
    $data = trim($data);
    $data = stripslashes($data);
    $data = htmlspecialchars($data);
    return $data;
}
?>

<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="refresh" content="0; url=<?php 
echo $_SERVER['HTTP_REFERER'];
?>
" />
</head>
<body>
  <h1>
  </h1>
Exemplo n.º 3
0
<?php 
// handler.php
// handle comment posts, saving to MySQL and redirecting back to the list
require_once "Dao.php";
if (isset($_POST["commentButton"])) {
    $comment = $_POST["comment"];
    try {
        $dao = new Dao();
        $dao->saveComment($comment);
    } catch (Exception $e) {
        var_dump($e);
        die;
    }
}
header("Location:index.php");
?>