TAS-ALFA/admin-zone/insert.php

24 lines
684 B
PHP
Raw Normal View History

2018-11-17 14:43:50 +01:00
<?php
if( !isset( $_SESSION ) ) session_start();
include "../settings/db_connect.php";
$title = $_POST["title"];
$meta_desc = $_POST["meta_desc"];
$text = $_POST["post_text"];
$userlogin=$_SESSION['user'];
$query="SELECT user_id FROM user WHERE username='$userlogin'";
if ($result=mysqli_query($mysqli,$query)){
while ($row=mysqli_fetch_row($result)){
$userid=$row[0];
}
}
$sql = $mysqli->prepare("INSERT INTO post VALUES (NULL,?, ?, ?, ?,NOW(),NOW());");
if ($sql)
{
$sql->bind_param("isss",$userid,$title,$meta_desc,$text);
$sql->execute();
$sql->close();
}
$mysqli->close();
header ("Location: http://127.0.0.1/TAS-ALFA/admin-zone/");
?>