Skip to content

Instantly share code, notes, and snippets.

@achshar
Forked from samroar/gist:cc9516a3aa59c52ea481
Last active August 29, 2015 14:03
Show Gist options
  • Save achshar/3e0a9f2707e7b4a6d979 to your computer and use it in GitHub Desktop.
Save achshar/3e0a9f2707e7b4a6d979 to your computer and use it in GitHub Desktop.
<?php
if(!empty($_POST)) {
$dbh = new PDO('mysql:dbname=reddit;host:localhost', 'root', '', array(PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING));
$query = $db->prepare('INSERT INTO posts (title, subreddit) VALUES (?, ?)');
$query->execute(array($_POST['title'], $_POST['subreddit']));
echo $_POST['id'];
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment