Skip to content

Instantly share code, notes, and snippets.

@samroar
Created July 2, 2014 11:11
Show Gist options
  • Save samroar/cc9516a3aa59c52ea481 to your computer and use it in GitHub Desktop.
Save samroar/cc9516a3aa59c52ea481 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));
$title = $_POST['title'];
$subreddit = $_POST['subreddit'];
$sql='INSERT INTO posts (title, subreddit) VALUES (?, ?)';
echo $title, $subreddit;
$query=$db->prepare($sql);
$query->execute(array($title, $subreddit));
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment