Created
July 17, 2014 16:22
-
-
Save samroar/66dd5600e47f5a6401aa 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
| html | |
| <!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="posts.php" method="POST"> | |
| <label for ='id'>id</label> | |
| <input type="number" name="id" /> | |
| <label for = 'title'>Title</label> | |
| <input type="text" name="title" /> | |
| <label for = 'sub'>subreddit</label> | |
| <input type="text" name="subreddit" /> | |
| <label for ='user'>user</label> | |
| <input type="text" name="user" /> | |
| <label for ='url'>url</label> | |
| <input type="text" name="url" /> | |
| <input type="submit"> | |
| </form> | |
| </body> | |
| </html> | |
| php | |
| <?php | |
| if(!empty($_POST)) { | |
| $dbh = new PDO('mysql:dbname=reddit;host:localhost', 'root', '', array(PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING)); | |
| $query = $dbh->prepare('INSERT INTO posts (title, subreddit, user, url) VALUES (?, ?, ?, ?)'); | |
| $query->execute(array($_POST['title'], $_POST['subreddit'], $_POST['user'], $_POST['url'])); | |
| echo $_POST['title']; | |
| echo $_POST['subreddit']; | |
| echo $_POST['user']; | |
| echo $_POST['url']; | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment