Created
July 1, 2014 12:08
-
-
Save samroar/044bc36bbbe17b58a481 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if(empty($_post)) {} | |
else { | |
$dbh = new PDO('mysql:dbname=reddit;host:localhost', 'root', '', array(PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING)); | |
$form = $_post; | |
$id = $form['id']; | |
$title = $form['title']; | |
$subreddit = $form['subreddit']; | |
$sql="INSERT INTO posts (id, title, subreddit) VALUES ('', :title, :subreddit)"; | |
$query=$db->prepare($sql); | |
$query->execute(array( 'id'=>$id, ':title'=>$title, ':subreddit'=>$subreddit)); | |
$dbh->query("SELECT id,title,subreddit FROM posts"); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment