<?php

ob_start();

if (!session_start()) {
    session_start();
}

try {
    $db = new PDO('mysql:host=localhost;dbname=gdhhsxmy_monsoonvibespublica;charset=utf8', 'gdhhsxmy_monsoonvibespublica', 'monsoonvibespublica');
} catch (Exception $e) {
    echo 'Error has Occured';
}



$n1 = $_POST['id'];
$n2 = $_POST['title'];

$n4 = addslashes($_POST['description']);


$file      = $_FILES['photo'];
$filename  = $file['name'];
$filepath  = $file['tmp_name'];
$fileerror = $file['error'];




$stmt = $db->prepare("UPDATE review SET title='$n2',description='$n4'  where id=$n1 ");
$stmt->execute();




if ($filename) {
    $path = '../../pic/review/' . $n1;
    unlink($path);
    $picname = $n1;
    $stmt    = $db->prepare("Update review set image='$picname' where id=$n1");
    $stmt->execute();


    $destfile = '../../pic/review/' . $picname;
    //ECHO  $destfile;

    move_uploaded_file($filepath, $destfile);
}



header('location:../review.php');
exit();
