Hi guys. im new to php so this is probably an easy spot for you guys but its doing my head in. im trying to insert data into a table using pdo. im not getting any error messages or anything its just not going in. any help is greatly appreciated. heres the code
MAIN PAGE
`<?php require_once(“includes/db.php”);?>
<?php require_once(“includes/functions.php”);?>
<?php require_once(“includes/sessions.php”);?>
<?php
if (isset($_POST[“submit”])){
$catagory = $
$admin = “Cole”;
date_default_timezone_set(“Europe/Dublin”);
$currenttime = time();
$datetime= strftime(“%B-%d-%Y %H:%M:%S”, $currenttime);
if (empty($catagory)){
$_SESSION[“error”] = “please fill in the form correctly”;
redirect(“catagory.php”);
} elseif (strlen($catagory)<3){
$
redirect(“catagory.php”);
}elseif(strlen($catagory)>49){
$_SESSION[“error”] = “catagory is too long”;
redirect(“catagory.php”);
}else {
$sql = “INSERT INTO catagory(title,author,datetime) VALUES(:catagoryname,:adminname,:dateTime)”;
$stmt = $connect->prepare($sql);
$stmt->bindValue(‘:catagoryname’, $catagory);
$stmt->bindValue(‘:adminname’, $admin);
$stmt->bindValue(‘:dateTime’, $datetime);
$Execute = $stmt->execute();
if($Execute){
$_SESSION[“success”] = “data added successfully”;
redirect(“basic.html”);
}else {
$_SESSION[“error”] = “something went wrong. data not added to table”;
redirect(“catagory.php”);
}
}
}
?>
<!doctype html>
<html>
<head>
<meta charset=”utf-8″>
<meta name=”viewport” content=”width=device-width, initial-scale=1.0″>
<meta http-equiv=”X-UA-compatible” content=”ie=edge”>
<title>Catagories</title>
<link rel=”stylesheet” href=”
<link rel=”stylesheet” href=”
<link rel=”stylesheet” href=”css/styles.css”>
</head>
<body>
<!– NAVBAR START –>
<div style=”height:10px; background-color:rgb(100,100,100);”></div>
<nav class=”navbar navbar-expand-lg bg-dark navbar-dark”>
<div class=”container”>
<a href=”#” class=”navbar-brand”>jazebakram.com</a>
<button class=”navbar-toggler” data-toggle=”collapse” data-target=”#navbarcollapsecms”><span class=”navbar-toggler-icon”></span></button>
<div class=”collapse navbar-collapse” id=”navbarcollapsecms”>
<ul class=”navbar-nav mr-auto”>
<li class=”nav-item”><a href=”myprofile.php” class=”nav-link”> <i class=”fas fa-user”></i> Profile</a></li>
<li class=”nav-item”><a href=”dashboard.php” class=”nav-link”>Dashboard</a></li>
<li class=”nav-item”><a href=”posts.hp” class=”nav-link”>Posts</a></li>
<li class=”nav-item”><a href=”catagories.php” class=”nav-link”>Catagories</a></li>
<li class=”nav-item”><a href=”admins.php” class=”nav-link”>Manage admins</a></li>
<li class=”nav-item”><a href=”comments.php” class=”nav-link”>Comments</a></li>
<li class=”nav-item”><a href=”blog.php?page=1″ class=”nav-link”>Live blog</a></li>
</ul>
<ul class=”navbar-nav ml-auto”>
<li class=”nav-item”><a href=”logout.php” class=”nav-link”><i class=”fas fa-user-times”></i> Log out</a></li>
</ul>
</div>
</div>
</nav>
<div style=”height:10px; background-color:rgb(100,100,100);”></div>
<!– NAVBAR END –>
<!– HEADER START –>
<header class=”bg-dark text-white”>
<div class=”container”>
<div class=”row”>
<h1> <i class=”fas fa-edit style=”color: #27aae1;”></i> Manage catagories</h1>
</div>
</div>
</header>
<!– HEADER END –>
<!– MAIN AREA –>
<section class=”container py-2 mb-4″>
<div class=”row”>
<div class=”offset-lg-1 col-lg-10″ style=”min-height: 600px;”>
<?php
echo errormessage();
echo successmessage();
?>
<form action=”catagory.php” method=”post”>
<div class=”card bg-secondary text-light “>
<div class=”card-header”>
<h1>Add new catagory</h1>
</div>
</div>
<div class=”card-body bg-dark” >
<div class=”form-group”>
<label for=”title”><span class=”fieldinfo”>Catagory title:</span></label>
<input class=”form-control” type=”text” name=”title” id=”title” value=””>
</div>
<div class=”row”>
<div class=”col-lg-6 mb-2″>
<a href=”dashboard.php” class=”btn btn-warning btn-lg btn-block”><i class=”fas fa-arrow-left”>Back to dashboard</i></a>
</div>
<div class=”col-lg-6 mb-2″>
<button type=”submit” name=”submit” class=”btn btn-success btn-lg btn-block”><i class=”fas fa-check”>Publish</i></button>
</div>
</div>
</div>
</form>
</div>
</div>
</section>
<!– FOOTER START –>
<footer class=”bg-dark text-white”>
<div class-“container”>
<div class=”row”>
<div class=”col”>
<p class=”lead text-center”>Theme by Cole Pratt</p>
</div>
</div>
</div>
</footer>
<script src=”https://code.jquery.com/jquery-3.3.1.slim.min.js” integrity=”sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo” crossorigin=”anonymous”></script>
<script src=”https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js” integrity=”sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1″ crossorigin=”anonymous”></script>
<script src=”https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js” integrity=”sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM” crossorigin=”anonymous”></script>
</body>
</html>
`DATABASE CONNECT FILE
`
$DSN = “mysql:host = localhost, dbname=cms”;
$connect = new PDO($DSN, ‘root’, ”);
?>`
FUNCTIONS FILE
`<?php
function redirect($new_target){
header(“Location:”.$new_target);
exit;
}
?>
`
SESSIONS FILE
`<?php
SESSION_START();
function errormessage(){
if (isset($_SESSION[“error”])){
$output = “<div class=”alert alert-danger”>”;
$output .= htmlentities($
$output .= “</div>”;
$_SESSION[“error”] = null;
return $output;
}
}
function successmessage(){
if (isset($_SESSION[“success”])){
$output = “<div class=”alert alert-success”>”;
$output .= htmlentities($
$output .= “</div>”;
$_SESSION[“success”] = null;
return $output;
}
}
?>
`
THATS IT. THANKS IN ADVANCE