i did all right but not getting rquierd results. using php and mysqli commands i want to insert data. actually im making a CMS system as practice work. not sure how to do it please HELP!
some screen shots here
code here
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Personal Home Page</title>
<!-- Bootstrap -->
<link href="css/bootstrap.css" rel="stylesheet">
<link href="css/custom.css" rel="stylesheet">
<link rel="stylesheet" href="css/footer-distributed-with-address-and-phones.css">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="jumbotron-2">
<h1 style="text-align:left">Write your New Post</h1>
<form class="form-horizontal" method="post" action="new_post.php" enctype="multipart/form-data">
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">Post Title*:</label>
<div class="col-sm-10">
<input type="name" class="form-control" name="title" placeholder="Title of Post">
</div>
</div>
<div class="form-group">
<label for="inputPassword3" class="col-sm-2 control-label">Post Author*</label>
<div class="col-sm-10">
<input type="name" class="form-control" name="author" placeholder="Published By">
</div>
</div>
<div class="form-group">
<label for="inputPassword3" class="col-sm-2 control-label">File(img/vid:)*</label>
<div class="col-sm-10">
<input type="file" name="image" class="form-control" placeholder="image or video file">
</div>
</div>
<div class="form-group">
<label for="inputPassword3" class="col-sm-2 control-label">Post Content:*</label>
<div class="col-sm-10">
<textarea rows="15" cols="100" name="content" class="form-control" placeholder="content goes here"></textarea>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" name="submit" class="btn btn-success btn-lg" style="align-items:center">Publish</button>
<button type="reset" class="btn btn-danger btn-lg" style="align-items:center">Cancle</button>
</div>
</div>
</form>
</div>
<div style="background-color:#000000">
<div style="color:#FFFFFF" class="btn btn-danger btn-lg"><a href="backend.php">Backend</a></div>
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="js/jquery-1.11.2.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/bootstrap.js"></script>
</body>
</html>
<?php
include("includes/connect.php");
if (isset($_POST['submit']))
{
$title=$_POST['title'];
$author=$_POST['author'];
$content=$_POST['content'];
$image_name = $_FILES['image']['name'];
$image_type = $_FILES['image']['type'];
$image_size = $_FILES['image']['size'];
$image_tmp = $_FILES['image']['tmp_name'];
if ($title=='' or $author=='' or $content==''){
echo "<script>alert('Do not let any field empty')</script>";
exit();
}
if($image_type=="image/jpeg" or $image_type=="image/png" or $image_type=="image/gif"){
if($image_size<=5000000){
move_uploaded_file($image_tmp, "img/$image_name");
}
else{
echo "<script>alert('image is greater')</script>";
}
}
else{
echo "<script>alert('image type is invalid')</script>";
}
$sql="INSERT INTO posts(post_title, post_author, post_img, post_content) VALUES($title,$author,$image_name,$content)";
$link = mysqli_connect("localhost", "root", " ", "firstwebsitedb");
if (mysqli_query($link,$sql)){
echo "<script>alert('Post is Published')</script>";
}
else{
echo "<script>alert('Post is not Published')</script>";
}
}
?>