This file contains 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 action="comments.php" method="POST"> | |
<label for="id">id</label> |
This file contains 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 = $db->prepare('INSERT INTO posts (title, subreddit) VALUES (?, ?)'); | |
$query->execute(array($_POST['title'], $_POST['subreddit'])); | |
echo $_POST['id']; | |
} | |
?> |
This file contains 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($_POST) { | |
$dbh = new PDO('mysql:dbname=reddit;host:localhost', 'root', '', array(PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING)); | |
$query = $db->prepare('INSERT INTO posts (title, subreddit) VALUES (?, ?)'); | |
$query->execute(array($_POST['title'], $_POST['subreddit'])); | |
} ?> |