Created
July 20, 2014 16:04
-
-
Save samroar/064da086d19278b6acac 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 | |
| if(!empty($_POST)) { | |
| $dbh = new PDO('mysql:dbname=reddit;host:localhost', 'root', '', array(PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING)); | |
| $rows = $dbh->query("SELECT * from posts where id = ?"); | |
| $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="comments.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