Created
August 1, 2014 12:25
-
-
Save samroar/7b362bae49f2cfa0c9da 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 | |
| $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> | |
| <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">Post<input type="text" name="post" /></label> | |
| <label="body">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