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 | |
| $dsn= 'mysql:dbname=reddit;host:localhost'; | |
| $user='root'; | |
| $password=''; | |
| $dbh = new PDO($dsn, $user, $password, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING)); | |
| $sql="INSERT INTO posts (id, title) VALUES ('', ?)"; | |
| $dbh->query("SELECT title FROM posts"); | |
| ?> |
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)) {} | |
| 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); |
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)) {} | |
| else { | |
| $dbh = new PDO('mysql:dbname=reddit;host:localhost', 'root', '', array(PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING)); | |
| $title = $_POST['title']; | |
| $subreddit = $_POST['subreddit']; | |
| $sql='INSERT INTO posts (title, subreddit) VALUES (?, ?)'; | |
| $query=$db->prepare($sql); | |
| } | |
| ?> |
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)) {} | |
| else { | |
| $dbh = new PDO('mysql:dbname=reddit;host:localhost', 'root', '', array(PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING)); | |
| $title = $_POST['title']; | |
| $subreddit = $_POST['subreddit']; | |
| $sql='INSERT INTO posts (title, subreddit) VALUES (?, ?)'; | |
| $query=$db->prepare($sql); | |
| $query->execute(array($title, $subreddit)); | |
| } |
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
| <!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> | |
| <form action="http://localhost/reddit/redditform.php" method="POST"> |
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)); | |
| $title = $_POST['title']; | |
| $subreddit = $_POST['subreddit']; | |
| $sql='INSERT INTO posts (title, subreddit) VALUES (?, ?)'; | |
| echo $title, $subreddit; | |
| $query=$db->prepare($sql); | |
| $query->execute(array($title, $subreddit)); | |
| } |
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
| <!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> | |
| <form action="redditform.php" method="POST"> |
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> |
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)); | |
| $query = $dbh->prepare('INSERT INTO comments (user, body) VALUES (?, ?)'); | |
| $query->execute(array($_POST['user'], $_POST['body'])); | |
| echo $_POST['user']; | |
| echo $_POST['body']; | |
| } | |
| Select * from `post` inner join `comments` on `post`.`id` = `comments`.`post_id` | |
| ?> |
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)); | |
| $query = $dbh->prepare('INSERT INTO comments (post, user, body) VALUES (?, ?, ?)'); | |
| $query->execute(array($_POST['user'], $_POST['body'], $_POST['post'])); | |
| echo $_POST['post']; | |
| echo $_POST['user']; | |
| echo $_POST['body']; | |
| } | |
| ?> |