Created
August 10, 2014 20:19
-
-
Save samroar/9019d67a1b671e4c9fc1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
| $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> | |
| <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="post.php" method="POST"> | |
| <label>Post<input type="text" name="post" /></label> | |
| <label>Body<input type="text" name="body" /></label> | |
| <input type="submit"> | |
| </form> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment