hi there, i wonder if you can help. i am trying to follow a tutorial and i have followed it exactly but when it comes to inserting data into the database it is not doing so. it says it is connected. here are my files. many thanks for the help.
bodyleft.php
<div id="bodyleft"><h3>Content Mangerment System</h3>
<ul>
<li><a href="index.php">Home</a></li>
<h3>Category Management</h3>
<li><a href="index.php?viewall_cat">Viewall Categories</a></li>
<li><a href="index.php?viewall_sub_cat">Viewall Sub Categories</a></li>
<h3>Product Management</h3>
<li><a href="index.php?add_products">Add New Products</a></li>
<li><a href="index.php?viewall_products">View All Products</a></li>
<li><a href="index.php?dis_pro">View All Discount Products</a></li>
<li><a href="index.php?wish">View All WishList Products</a></li>
<li><a href="index.php?out_stock">View All Out Of Stock Products</a></li>
<h3>Order Management</h3>
<li><a href="index.php?complete_order">View All Complete Orders</a></li>
<li><a href="index.php?pending_order">View All Pending Orders</a></li>
<li><a href="index.php?cancle_order">View All Cancle Orders</a></li>
<h3>Other Management</h3>
<li><a href="index.php?customer">View All Customers</a></li>
<li><a href="index.php?country">View All Country</a></li>
<li><a href="index.php?state">View All State</a></li>
<li><a href="index.php?slider">Edit Image Slider</a></li>
</ul>
</div>
<?php
if(isset($_GET['viewall_cat'])){
include("cat.php");
}
?>
bodyright.php
<?php
if(!isset($_GET['viewall_cat'])){ ?>
<div id="bodyright"></div>
<?php }?>
cat.php
<div id="bodyright">
<h3>View All Categories</h3>
<form method="post">
<table cellspacing="0">
<tr>
<td>Enter Category Name :</td>
<td><input type="text" name="cat_name" /></td>
</tr>
</table>
<center><button name="add_cat">Add Category</button></center>
</form>
</div>
<?php include("inc/dbtest.php");
if(isset($_POST['add_cat'])){
$cat_name=$_POST['cat_name'];
$add_cat=$con->prepare("insert into main_cat(cat_name)values('$cat_name')");
$add_cat->execute();
}
?>
dbtest.php
<?php
$servername = "";
$username = "";
$password = "";
try {
$conn = new PDO("mysql:host=$servername;dbname=bargaincentre1_store", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "Connected successfully";
}
catch(PDOException $e)
{
echo "Connection failed: " . $e->getMessage();
}
?>