Skip to content

Instantly share code, notes, and snippets.

<?php
$dbh = new PDO('mysql:dbname=reddit;host:localhost', 'root', '', array(PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING));
if(!empty($_POST)) {
$query = $dbh->prepare('INSERT INTO comments (post, user, body) VALUES (?, ?, ?)');
$query->execute(array($_POST['post'], '', $_POST['body']));
header("Location: " . "http://" . $_SERVER['HTTP_HOST'] . "/reddit/post.php");
}
$rows=$dbh->prepare("SELECT title, user, subreddit, url, timestamp from posts where id='?'");
$rows->execute(array($_GET['title'], '', $GET['subreddit'], $GET['url'], $GET['timestamp']));
foreach($rows as $row) { ?>
<?php
$dbh->query("SELECT id, title, user, subreddit, url, timestamp from posts where id='1'");
if(!empty($_POST)) {
$dbh = new PDO('mysql:dbname=reddit;host:localhost', 'root', '', array(PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING));
$query = $dbh->prepare('INSERT INTO comments (post, user, body) VALUES (?, ?, ?)');
$query->execute(array($_POST['post'], '', $_POST['body']));
header("Location: " . "http://" . $_SERVER['HTTP_HOST'] . "/reddit/post.php");
}
?>
<!DOCTYPE HTML>
<?php
if(!empty($_POST)) {
$dbh = new PDO('mysql:dbname=reddit;host:localhost', 'root', '', array(PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING));
$query = $dbh->prepare('INSERT INTO comments (post, user, body) VALUES (?, ?, ?)');
$query->execute(array($_POST['post'], '', $_POST['body']));
header("Location: " . "http://" . $_SERVER['HTTP_HOST'] . /http://localhost/reddit/post.php
}
?>
<!DOCTYPE HTML>
<html>
<?php
if(!empty($_POST)) {
$dbh = new PDO('mysql:dbname=reddit;host:localhost', 'root', '', array(PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING));
$query = $dbh->prepare('INSERT INTO comments (post, user, body) VALUES (?, ?, ?)');
$query->execute(array($_POST['post'], '', $_POST['body']));
}
?>
<!DOCTYPE HTML>
<html>
<head>
<!doctype HTML>
<html>
<head>
<title>reddit: the front page of the internet</title>
<link href="reddit.css" rel="stylesheet"/>
<script src ="reddit.js" type="text/javascript"></script>
</head>
<body>
<form action="" method="POST">
<label><br>Title </br><input type="text" name="title" /></label>
#
# This is the main Apache HTTP server configuration file. It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/2.4/> for detailed information.
# In particular, see
# <URL:http://httpd.apache.org/docs/2.4/mod/directives.html>
# for a discussion of each configuration directive.
#
# Do NOT simply read the instructions in here without understanding
# what they do. They're here only as hints or reminders. If you are unsure
#
# This is the main Apache HTTP server configuration file. It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/2.4/> for detailed information.
# In particular, see
# <URL:http://httpd.apache.org/docs/2.4/mod/directives.html>
# for a discussion of each configuration directive.
#
# Do NOT simply read the instructions in here without understanding
# what they do. They're here only as hints or reminders. If you are unsure
# Virtual Hosts
#
# Required modules: mod_log_config
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
<?php
$rows = $dbh->query("SELECT * from posts where id = ?");
if(!empty($_POST)) {
$dbh = new PDO('mysql:dbname=reddit;host:localhost', 'root', '', array(PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING));
$query = $dbh->prepare('INSERT INTO comments (post, user, body) VALUES (?, ?, ?)');
$query->execute(array($_POST['post'], '', $_POST['body']));
}
?>
<!DOCTYPE HTML>
<html>
<?php
$rows = $dbh->query("SELECT * from posts where id = ?");
if(!empty($_POST)) {
$dbh = new PDO('mysql:dbname=reddit;host:localhost', 'root', '', array(PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING));
$query = $dbh->prepare('INSERT INTO comments (post, user, body) VALUES (?, ?, ?)');
$query->execute(array($_POST['post'], '', $_POST['body']));
}
?>
<!DOCTYPE HTML>
<html>