This question already has an answer here:
<?php
session_start();
// initializing variables
$title = "";
$categories = "";
$profile = "";
$description = "";
$errors = array();
// connect to the database
$conn = mysqli_connect("localhost", "root", "", "blogs");
// CREATE BLOGS
if (isset($_POST['blog_submit'])) {
// receive all input values from the form
$title = mysqli_real_escape_string($conn, $_POST['title']);
$categories = mysqli_real_escape_string($conn, $_POST['categories']);
$profile = mysqli_real_escape_string($conn, $_FILES['profile']['name']);
$description = mysqli_real_escape_string($conn, $_POST['description']);
// by adding (array_push()) corresponding error unto $errors array
if (empty($title)) {
array_push($errors, "Title is required");
}
if (empty($categories)) {
array_push($errors, "Category is required");
}
if (empty($profile)) {
array_push($errors, "Profile is required");
}
if (empty($description)) {
array_push($errors, "Description is required");
}
if (count($errors) == 0) {
$q2 = "INSERT INTO category (title, categories, profile, description)
VALUES('$title', '$categories','$profile', '$description')";
mysqli_query($conn, $q2);
// $q2="INSERT INTO categories (title, categories, profile, description)
// VALUES('$title', '$categories','$profile', '$description')";
// $run=mysqli_query($conn, $q2);
// while($row=mysqli_fetch_array($run))
}
}
?>
It gives error that Notice undefined: categories on line 19 and Notice undefined: description line, how to get define categories and description? help me how to get initialize the description and categories.
</div>