I am building a simple blog system where I can post entries through a php page to the database in mysql. Whenever I post an entry it doesn't seem to appear on the database and I can't find the issue. Here is my php:
<?php
error_reporting(E_ALL & ~E_NOTICE);
session_start();
if(isset($_SESSION['username']))
{
$username = ucfirst($_SESSION['username']);
if($_POST['submit']) {
$title = $_POST['title'];
$subtitle = $_POST['subtitle'];
$content = $_POST['content'];
include_once("connection.php");
$sql = "INSERT INTO blog (title, subtitle, content) VALUES ('$title', '$subtitle', '$content')";
mysqli_query($dbCon, $sql);
echo "Blog entry posted";
}
}
else{
header('Location: login.php');
die();
}
?>
The title, subtitle and content tags are in a html below this and they take values which I intend to send to the database. This is the html:
<form method="post" action="admin.php">
Title:<input type="text" name="title" /><br />
Subtitle: <input type="text" name="subtitle" /><br />
Content:<textarea name="content"></textarea>
<input type="submit" name="submit" value="Post Blog Entry" />
</form>
And the connection to the database is:
<?php
$dbCon = mysqli_connect("localhost","root","","learnlearn");
if(mysqli_connect_errno())
{
echo "Failed to connect: " . mysqli_connect_error();
}
?>