I'm making a Pastebin-esque project on my free time and it only recently hit me that I need to have a title for the pastes. I'm using PDO, and I pretty much had to redo the entire php script that inserts already, and now I can't figure out what's wrong. Here's the body of my HTML to begin with, paste.html:
<form action="insert.php" method="post">
Title: <input type="text" name="title">
<br>
Paste: <br> <input type="text" name="paste">
<input type="submit" value="insert">
</form>
And here's my insert.php:
require 'connection.php';
$paste = $_POST['paste'];
$title = $_POST['title'];
$sql = "INSERT INTO pasteinfo (title, paste) VALUES (:title, :paste)";
$stmt = $con->prepare($sql);
$stmt->bindParam(':paste', $paste);
$stmt->bindParam(':title', $title);
$stmt->execute();
$con = null;
I really don't know what's wrong here. Thanks!
EDIT: connection.php looks like this:
try {
$con = new pdo("mysql:host='';dbname='pastes'",'','','pasteinfo');
echo "connected successfully";
} catch (PDOException $e) {
echo "Connection failed: " . $e->getMessage();
}