I am learning PHP, and would like to know if there is any way to hide an option depending on what I get,
basiccaly this is my code it's simple.
<?php
require 'database.php';
session_start();
if(!isset($_POST['update'])){
$id=$_GET['id'];
$state=$_GET['state'];
$sql="SELECT * from states";
$show=$conn->prepare($sql);
$show->execute();
$result = $show->fetchAll(PDO::FETCH_ASSOC);
}else{
$id=$_POST['id'];
$state=$_POST['state'];
$sql="UPDATE pqrs SET fk_state=:fk_state WHERE idPqrs=:id";
$update=$conn->prepare($sql);
$update->bindParam(':id',$_POST['id']);
$update->bindParam(':fk_state',$_POST['state']);
$update->execute();
}
?>
<!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.0">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<title>Document</title>
</head>
<body>
<body>
<div class="ml-5"><?php require 'partials/header.php' ?></div>
<div class="container col-5">
<h1 class="text-center mb-5">Extreme Techonologics</h1>
<h2 class="text-center">Ingrese los campos a cambiar</h2>
<form action="pqr_update.php" method="POST">
<div class="form-group">
<input type="hidden" value="<?php echo $id?>" class="form-control" name="id">
</div>
<div class="form-group my-5">
<label for="pqr_type">Seleccione el estado del PQR:</label>
<select class="form-control" id="state" name="state">
<?php foreach($result as $state):?>
<option value="<?php echo $state['idState'];?>"><?php echo $state['state'];?></option>
<?php endforeach ?>
</select>
</div>
<button type="submit" class="btn btn-primary" name="update">Enviar</button>
</form>
</div>
Cerrar Sesión
</body>
</html>
</html>
Basically I would like to know if when $ _GET = ['state'] = 'Nuevo', when I press the button (name = 'update') what I receive from the POST, it only shows me an option (En Ejecución), in theory there are 3 states , Nuevo, En Ejecución and Cerrado. When the status is ¿Nuevo' I don't want it to show me the option "EN Ejecucuion" and when the option received is "EN Ejecucuion" I do not want it to show me the option 'Nuevo'.
Based on the above requirement, try this:
<?php
require 'database.php';
session_start();
if(!isset($_POST['update'])){
$id=$_GET['id'];
$state=$_GET['state'];
$sql="SELECT * from states";
$show=$conn->prepare($sql);
$show->execute();
$result = $show->fetchAll(PDO::FETCH_ASSOC);
}else{
$id=$_POST['id'];
$state=$_POST['state'];
$sql="UPDATE pqrs SET fk_state=:fk_state WHERE idPqrs=:id";
$update=$conn->prepare($sql);
$update->bindParam(':id',$_POST['id']);
$update->bindParam(':fk_state',$_POST['state']);
$update->execute();
}
?>
<!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.0">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<title>Document</title>
</head>
<body>
<body>
<div class="ml-5"><?php require 'partials/header.php' ?></div>
<div class="container col-5">
<h1 class="text-center mb-5">Extreme Techonologics</h1>
<h2 class="text-center">Ingrese los campos a cambiar</h2>
<form action="pqr_update.php" method="POST">
<div class="form-group">
<input type="hidden" value="<?php echo $id?>" class="form-control" name="id">
</div>
<div class="form-group my-5">
<label for="pqr_type">Seleccione el estado del PQR:</label>
<select class="form-control" id="state" name="state">
<?php
foreach($result as $state):
if (
($_REQUEST['state'] == '¿Nuevo\'' && $state['state'] != 'EN Ejecucuion')
&&
($_REQUEST['state'] == 'EN Ejecucuion' && $state['state'] != '¿Nuevo\'')
):
?>
<option value="<?php echo $state['idState'];?>"><?php echo $state['state'];?></option>
<?php endif; endforeach; ?>
</select>
</div>
<button type="submit" class="btn btn-primary" name="update">Enviar</button>
</form>
</div>
Cerrar Sesión
</body>
</html>
</html>
Related
I am trying to use select2 for my laravel Create function. but it does nothing, and i followed multiple tutorials with the same results.
index.blade(my scripts are in the header)
<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">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<link href="{{ asset('css/app.css') }}" rel="stylesheet">
<title>Subfolders</title>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/css/select2.min.css" integrity="sha512-nMNlpuaDPrqlEls3IX/Q56H36qvBASwb3ipuo3MxeWbsQB1881ox0cRv7UPTgBlriqoynt35KjEwgGUeUXIPnw==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/js/select2.min.js" integrity="sha512-2ImtlRlf2VVmiGZsjm9bEyhjGW4dU7B6TNwh/hx/iSByxNENtj3WVE6o/9Lj4TJeVXPi4bnOIMXFIJJAeufa0A==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
#stack('page_scripts')
</head>
#include('admin.file.create')
here i include the 'create.blade' file
create.blade:
<div class="row">
<div class="col-sm-8 offset-sm-2">
<h1 class="display-3">Add File</h1>
<div>
#if ($errors->any())
<div class="alert alert-danger">
<ul>
#foreach ($errors->all() as $error)
<li>{{ $error }}</li>
#endforeach
</ul>
</div><br />
#endif
<form method="post" action="{{ route('admin.file.store') }}" enctype="multipart/form-data">
#csrf
<div class="form-group">
<label for="title">{{('title')}}*</label>
<input type="text" class="form-control" name="title" />
</div>
<div class="form-group">
<label for="value">{{('Short description')}}</label>
<input type="text" class="form-control" name="description_short" />
</div>
<div class="form-group">
<label for="name">{{('Tags')}}*</label>
<select id="tag_ids" name="tag_id[]" class="form-control" multiple>
<option value="">{{('Select Tags')}}</option>
#foreach($tags as $tag)
<option value=" {{$tag->id}}">{{$tag->name}}</option>
#endforeach
</select>
</div>
<p>* required</p>
<button type="submit" class="btn btn-primary">Add File</button>
</form>
</div>
</div>
</div>
#push('page_scripts')
<script>
$(document).ready(function() {
$('#tag_ids').select2();
});
</script>
#endpush
image of the select:
if i need to upload any more information i will gladly do so!
You need to add jQuery CDN and call the select2 function. I have attached a sample code below.
<!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.0">
<title>Select2</title>
<!-- CSS -->
<link href="https://cdn.jsdelivr.net/npm/select2#4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
</head>
<body>
<select class="js-example-basic-single" name="state">
<option value="AL">Alabama</option>
<option value="WY">Wyoming</option>
</select>
<!-- JS -->
<script src="https://code.jquery.com/jquery-3.6.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/select2#4.1.0-rc.0/dist/js/select2.min.js"></script>
<script>
$(document).ready(function () {
$('.js-example-basic-single').select2();
});
</script>
</body>
</html>
This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 6 years ago.
`i have installed a script on my localhost and this error comes up when i try to run the login page. please i need help if there a problem with the code let me know thanks
Parse error: syntax error, unexpected end of file in C:\xampp\htdocs\dating\matchme271\MatchMe2\UPLOAD\index.php on line 180
line 180 is last line
<? php
session_set_cookie_params(172800);
session_start();
require('core/config.php');
require('core/auth.php');
require('core/system.php');
require('core/geo.php');
$auth = new Auth;
$geo = new Geo;
$system = new System;
$system->domain = $domain;
$system->db = $db;
$ip = $_SERVER['REMOTE_ADDR'];
if(isset($_POST['register'])) {
$full_name = ucwords($_POST['full_name']);
$email = $_POST['email'];
$password = trim($_POST['password']);
$time = time();
$age = $_POST['age'];
$gender = $_POST['gender'];
// Geolocation
$longitude = $_SESSION['longitude'];
$latitude = $_SESSION['latitude'];
$geo_info = $geo->getInfo($latitude,$longitude);
$city = $geo_info['geonames'][0]['name'];
$country = $geo_info['geonames'][0]['countryName'];
$check_d = $db->query("SELECT id FROM users WHERE email='".$email."'");
$check_d = $check_d->num_rows;
if($check_d == 0) {
$db->query("INSERT INTO users (profile_picture,full_name,email,password,registered,credits,age,gender,ip,country,city,longitude,latitude) VALUES ('default_avatar.png','$full_name','$email','".$auth->hashPassword($password)."','$time','100','$age','$gender','$ip','".$country."','".$city."','".$longitude."','".$latitude."')");
setcookie('justRegistered', 'true', time()+6);
setcookie('mm-email',$email,time()+60*60*24*30,'/');
header('Location: '.$domain.'/login');
exit;
}
}
if($auth->isLogged()) {
$first_name = $system->getFirstName($_SESSION['full_name']);
}
$users = $db->query("SELECT * FROM users ORDER BY RAND() LIMIT 7");
?>
<!DOCTYPE HTML>
<!--[if lt IE 7 ]><html class="ie ie6 ie-lt10 ie-lt9 ie-lt8 ie-lt7 no-js" lang="en"><![endif]-->
<!--[if IE 7 ]><html class="ie ie7 ie-lt10 ie-lt9 ie-lt8 no-js" lang="en"><![endif]-->
<!--[if IE 8 ]><html class="ie ie8 ie-lt10 ie-lt9 no-js" lang="en"><![endif]-->
<!--[if IE 9 ]><html class="ie ie9 ie-lt10 no-js" lang="en"><![endif]-->
<!--[if gt IE 9]><!-->
<html class="no-js" lang="en"><!--<![endif]-->
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta charset="utf-8">
<title><?php echo $site_name?> - Online Dating Community</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
<link href='//fonts.googleapis.com/css?family=Source+Sans+Pro:400,300,600,700' rel='stylesheet'>
<link href="<?=$system->getDomain()?>/assets/landing/font-awesome-4.3.0/css/font-awesome.min.css" rel="stylesheet">
<link href="<?=$system->getDomain()?>/assets/landing/animate.min.css" rel="stylesheet">
<link rel="stylesheet" href="<?=$system->getDomain()?>/assets/landing/bootstrap-social/bootstrap-social.css">
<link rel="stylesheet" href="<?=$system->getDomain()?>/assets/landing/styles.css">
</head>
<body>
<header class="header header3" role="banner" id="header" style="background-image: url('<?=$system->getDomain()?>/assets/landing/bg-header.jpg')">
<div class="container">
<div style="float:left;position:relative;z-index:2;"> <p><img src="<?=$system->getDomain()?>/img/logo-small.png"></p> </div>
<div class="cnt">
<h4>It’s quick & easy to</h4>
<h1 style="font-size:40px;" class="theme-color">Meet new people online</h1>
<p><?php echo $site_name?> is great for chatting, making friends, sharing interests, and even dating! Did we mention it's free?</p>
</div>
<div class="reg-form has-feedback">
<?php if(!$auth->isLogged()) { ?>
<i class="fa fa-sign-in fa-fw"></i> Log In
<br><br>
<h3>Register in one easy step</h3>
<form action="fb-login.php" method="POST">
<button type="submit" name="fb-login" class="btn btn-subsection btn-social btn-lg btn-facebook" style="text-align:left;"><i class="fa fa-facebook"></i>Log In with Facebook</button> <br>
</form>
<br>
<form action="" method="post" id="registration">
<input type="text" name="full_name" placeholder="Full name" required/>
<input type="text" name="email" placeholder="Email" required/>
<input type="password" name="password" placeholder="Password" required/>
<select name="age" autocomplete="off" required class="form-control">
<option value="" disabled selected>Age</option>
<?php for($i = $minimum_age; $i <= 100; $i++) { ?>
<option value="<?php echo $i?>"> <?php echo $i?> </option>
<?php } ?>
</select>
<select name="gender" autocomplete="off" required class="form-control">
<option value="" disabled selected>Gender</option>
<option value="Male"> Male </option>
<option value="Female"> Female </option>
</select>
<button type="submit" name="register" class="btn-red">Register today!</button>
</form>
<? } else { ?>
<div style="text-align:center;padding-top:50px;">
<h3>Welcome, <b><?=$first_name?></b> </h3>
<form action="<?=$system->getDomain()?>/people" method="GET">
<button type="submit" class="btn-red">Log In</button>
</form>
</div>
<? } ?>
</div>
</div>
</header>
<main class="front-page main" role="main">
<section class="profiles">
<div class="container">
<h3>Meet our community members</h3>
<div class="flexslider carousel">
<ul class="slides">
<?php while($user = $users->fetch_object()) { ?>
<li>
<div class="thumb">
<img src="<?=$system->getProfilePicture($user)?>" style="border-radius:5px;">
</div>
<p><?=$system->getFirstName($user->full_name)?></p>
<span><?=$user->age?>, <?=$user->country?></span>
</li>
<?php } ?>
</ul>
</div>
</div>
</section>
<section class="feature-section">
<h2><?php echo $site_name?> revolutionizes online dating <br/> Give it a try, it’s free to join. </h2>
<div class="container">
<div class="block">
<i class="fa fa-smile-o theme-color"></i>
<h3>It's Free</h3>
<p>
Signing up takes two
minutes and is totally free. What do you have to loose?
</p>
</div>
<div class="block">
<i class="fa fa-check theme-color"></i>
<h3>Smart Matching</h3>
<p>
Our matching algorithm helps
you find the right people.
</p>
</div>
<div class="block">
<i class="fa fa-map-marker theme-color"></i>
<h3>It's Localized</h3>
<p>Connect with the singles from your local <br> town or city.</p>
</div>
</div>
</section>
</main>
<script src="<?=$system->getDomain()?>/assets/landing/scripts/modernizr.js"></script>
<script src="<?=$system->getDomain()?>/assets/landing/scripts/jquery-1.11.0.min.js"></script>
<script src="<?=$system->getDomain()?>/assets/landing/scripts/jquery.flexslider-min.js"></script>
<script src="<?=$system->getDomain()?>/assets/landing/scripts/jquery.parallax-1.1.3.js"></script>
<script src="<?=$system->getDomain()?>/assets/landing/scripts/jquery.localscroll-1.2.7-min.js"></script>
<script src="<?=$system->getDomain()?>/assets/landing/scripts/jquery.scrollTo-1.4.2-min.js"></script>
<script src="<?=$system->getDomain()?>/assets/landing/scripts/jquery.inview.min.js"></script>
<script src="<?=$system->getDomain()?>/assets/landing/scripts/theme.js"></script>
<script>
navigator.geolocation.getCurrentPosition(getPosition);
function getPosition(position) {
$.get('<?=$system->getDomain()?>/ajax/setPosition.php?longitude='+position.coords.longitude+'&latitude='+position.coords.latitude);
}
</script>
</body>
</html>
The problem is lines like these:
<? } else { ?>
<? } ?>
The first <? should be <?php
I have made a simple form with a checkbox that echos out true or false depending on if the checkbox is set or not, however every time i click submit once the checkbox control has been ticked it seems to reset.
How can i modify my code to store the value of any form controls so if i tick the box it remains ticked after i have clicked submit?
<?php
// Setup Variables
$Result = '';
if (isset($_POST["submit"])) {
//Use Captials?
if(isset($_POST['formCheckbox']) && $_POST['formCheckbox'] == 'Yes') {
$Result = "true";
} else {
$Result = "false";
}
}
?>
<!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>Bootstrap Contact Form</title>
<link rel="stylesheet" href="css/bootstrap.min.css">
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-6 col-md-offset-3">
<h1 class="page-header text-center">Contact Form Example</h1>
<form class="form-horizontal" role="form" method="post" action="index.php">
Checkbox
<input type="checkbox" name="formCheckbox" value="Yes"/>
<div class="form-group">
<div class="col-sm-10 col-sm-offset-2">
<input id="submit" name="submit" type="submit" value="Send" class="btn btn-primary">
</div>
</div>
</form>
<div class="col-sm-10 col-sm-offset-2">
<?php echo $Result; ?>
</div>
</div>
</div>
</div>
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>
Add the checked property &
Change the way the check box is displayed:
<?php
// Setup Variables
$Result = '';
if (isset($_POST["submit"])) {
//Use Captials?
if(isset($_POST['formCheckbox']) && $_POST['formCheckbox'] == 'Yes') {
$Result = "true";
} else {
$Result = "false";
}
}
?>
<!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>Bootstrap Contact Form</title>
<link rel="stylesheet" href="css/bootstrap.min.css">
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-6 col-md-offset-3">
<h1 class="page-header text-center">Contact Form Example</h1>
<form class="form-horizontal" role="form" method="post" action="index.php">
Checkbox
<?php
if(isset($_POST['formCheckbox']) && $_POST['formCheckbox'] == 'Yes') {
echo '<input type="checkbox" name="formCheckbox" value="Yes" checked/>';
}
else
echo '<input type="checkbox" name="formCheckbox" value="Yes"/>';
?>
<div class="form-group">
<div class="col-sm-10 col-sm-offset-2">
<input id="submit" name="submit" type="submit" value="Send" class="btn btn-primary">
</div>
</div>
</form>
<div class="col-sm-10 col-sm-offset-2">
<?php echo $Result; ?>
</div>
</div>
</div>
</div>
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>
I am working with PHP session variables, but the problem is that the session variables are not carrying over. I checked using Firebug, and found that the session variables are not being created at all.
print_r($_SESSION); returns an empty array after the page returns to index.php, but displays it correctly before the refresh.
logincheck.php:
<?php
session_start();
error_reporting(-1);
if(isset($_SESSION['logged_in']) && $_SESSION['logged_in']==true)
{
$username=$_SESSION['username'];
?>
<!DOCTYPE html>
<html>
<head>
<title>Smart Shopping Cart System</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
<style type="text/css">
.show-grid{
background:#E0E0E0;
}</style>
</head>
<body>
<?php
include "connection.php"
?>
// ** Some Content**
</body>
</html>
<?php
}
else
{
?>
<html>
<head>
<title>Log In | SmartCart</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
</head>
<body>
<div class="navbar navbar-default">
<div class="container">
<div class="navbar-brand">
SmartCart
</div>
</div>
</div>
<div class="container">
<br />
<div class="row">
<div class="col-md-4">
</div>
<div class="col-md-4">
<form role="form" method="post" name="login" action="test.php">
<div class="form-group">
<label for="username">Operator Username</label>
<input type="username" class="form-control" name="username" placeholder="Enter your username">
</div>
<div class="form-group">
<label for="pass">Password</label>
<input type="password" class="form-control" name="pass" placeholder="Password">
</div>
<button type="submit" class="btn btn-default" name="sub">Submit</button>
</form>
</div>
<div class="col-md-3">
</div>
</div>
</div>
</body></html>
<?php
}
?>
test.php
<?php
session_start();
error_reporting(-1);
?>
<html><head><title>Redirecting...</title>
</head>
<body>
Redirecting....
<?php
include "connection.php";
if(isset($_POST['sub']))
{
$u_name=$_POST['username'];
$password=mysql_escape_string($_POST['pass']);
$password=mysql_escape_string($password);
$w="select * from operators where operator_username = '$u_name' AND operator_pass = '$password'";
$b=mysql_query($w) or die(mysql_error()."in query $w");
$num_rows = mysql_num_rows($b);
if($num_rows > 0)
{
$_SESSION['logged_in']=true;
$_SESSION['username']=$_POST['username'];
print_r($_SESSION);
echo '<meta http-equiv="refresh" content="0; url=index.php">';
}
else
{
echo "<script>
alert('Your username or password is incorrect. Please try again'); window.location = 'index.php'; </script>";
}
}
?>
</body></html>
Please help.
Spot the difference:
logincheck:
if(isset($_SESSION['logged_in']) && $_SESSION['logged_in']==true)
^^^^^^^^^
test:
$_SESSION["loggedin"]=true;
^^^^^^^^
One of these things is not like the other...
I think the under score is missing in on test.php page
in $_SESSION['loggedin']=true;
change this to $_SESSION['logged_in']=true;
As you are using this in
if(isset($_SESSION['logged_in']) && $_SESSION['logged_in']==true)
there is no error with you session part the error is may be in you db access part check your database connection. you can check you session by commenting the query part, it is working fine.
I have form for adding articles. I have 6 things (title,date,author,keywors,content,image) what I want to save to my database in localhost. But if I click on submit button in my database appear only 3 of them (title, date, image) but other nothing.
Any ideas how to solve it?
Here code for insert_post.php
<!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>APK Market</title>
<link rel="stylesheet" type="text/css" href="../style/style.css">
<link href="../bootstrap/css/bootstrap.css" rel="stylesheet" media="screen">
<script src="../bootstrap/js/bootstrap.min.js"></script>
<script src="../bootstrap/js/bootstrap.js"></script>
</head>
<body>
<?php
include("../includes/connect.php");
if(isset($_POST['submit']))
{
$post_date = date('y-m-d');
$post_title = $_POST['title'];
$post_author = $_POST['author'];
$post_keywords = $_POST['keywords'];
$post_image = $_FILES['image']['name'];
$image_tmp = $_FILES['image']['tmp_name'];
$post_content = $_POST['content'];
if($post_title=="" or $post_author="" or $post_keywords="" or $post_content="")
{
echo"<script>alert('any field is empty')</script>";
exit();
}
else
move_uploaded_file($image_tmp,"../uploaded_images/$post_image");
$insert_query = "insert into posts (post_title,post_date,post_author,post_image,post_keywords,post_content) values ('$post_title','$post_date','$post_author','$post_image','$post_keywords','$post_content')" ;
}
?>
<form method="post" action="insert_post.php" enctype="multipart/form-data">
<div class="new_post">
<div class="headtitle">Insert new post</div>
<div class="new_title">
<p>New title</p>
<input type="text" name="title">
</div>
<div class="new_author">
<p>Author</p>
<input type="text" name="author">
</div>
<div class="new_keywords">
<p>Keywords</p>
<input type="text" name="keywords">
</div>
<div class="new_image">
<p>Image</p>
<input type="file" name="image">
</div>
<div class="new_content">
<textarea name="content" cols="20" rows="8"></textarea>
</div>
<div class="submit">
<input type="submit" name="submit" value="OK">
</div>
</div>
</form>
<script src="https://code.jquery.com/jquery.js"></script>
<script src="../bootstrap/js/bootstrap.js"></script>
</body>
</html>
<?php
if(mysql_query($insert_query))
{
echo "<center><h1>Post published seccesfuly!</h1></center>";
}
?>
if($post_title=="" or $post_author="" or $post_keywords="" or $post_content="")
main error on HERE
replace it with
if($post_title=="" or $post_author=="" or $post_keywords=="" or $post_content=="")