Skip to content
Snippets Groups Projects
Commit 54adefd0 authored by daniarherikurniawan's avatar daniarherikurniawan
Browse files

update algorithm

parents ed2f90f8 df17127f
Branches
No related merge requests found
......@@ -44,42 +44,39 @@ if (isset($_SESSION["isLogin"]) && (isset($_POST['csrf_token']) && $_POST['csrf_
} else {
if (move_uploaded_file($_FILES["image"]["tmp_name"], $target_file)) {
echo "The file ". basename( $_FILES["image"]["name"]). " has been uploaded.<br>";
} else {
echo "Sorry, there was an error uploading your file.<br>";
}
}
}
$con = phpsqlconnection();
$getpostresult = getspecificpost($con,$postid);
$row = mysqli_fetch_array($getpostresult);
if ($row['Nama'] != $_SESSION['myNama']) {
echo "Maaf Anda bukan pemilik post ini!";
} else {
if (isset($_FILES["image"])) {
$stmt = $con->prepare("UPDATE post SET Title=?,Date=?, Contents=?, Image=? WHERE Post_Id=?");
$stmt->bind_param('ssssi', $Judul, $Tanggal, $Konten, $target_file, $postid);
$stmt->execute();
if ($row['Nama'] != $_SESSION['myNama']) {
echo "Maaf Anda bukan pemilik post ini!";
} else {
if (isset($_FILES["image"])) {
$stmt = $con->prepare("UPDATE post SET Title=?,Date=?, Contents=?, Image=? WHERE Post_Id=?");
$stmt->bind_param('ssssi', $Judul, $Tanggal, $Konten, $target_file, $postid);
$stmt->execute();
// mysqli_query($con,"UPDATE post SET Title='".$Judul."'".","."Date='".$Tanggal."'".","."Contents='".$Konten."'".", Image='".$target_file."' WHERE Post_Id=".$postid);
// echo "UPDATE post SET Title='".$Judul."'".","."Date='".$Tanggal."'".","."Contents='".$Konten."'".", Image='".$target_file."' WHERE Post_Id=".$postid;
}
else {
$stmt = $con->prepare("UPDATE post SET Title=?,Date=?, Contents=? WHERE Post_Id=?");
$stmt->bind_param('sssi', $Judul, $Tanggal, $Konten, $postid);
$stmt->execute();
// mysqli_query($con,"UPDATE post SET Title='".$Judul."'".","."Date='".$Tanggal."'".","."Contents='".$Konten."'".", Image='".$target_file."' WHERE Post_Id=".$postid);
// echo "UPDATE post SET Title='".$Judul."'".","."Date='".$Tanggal."'".","."Contents='".$Konten."'".", Image='".$target_file."' WHERE Post_Id=".$postid;
}
else {
$stmt = $con->prepare("UPDATE post SET Title=?,Date=?, Contents=? WHERE Post_Id=?");
$stmt->bind_param('sssi', $Judul, $Tanggal, $Konten, $postid);
$stmt->execute();
// mysqli_query($con,"UPDATE post SET Title='".$Judul."'".","."Date='".$Tanggal."'".","."Contents='".$Konten."'"."WHERE Post_Id=".$postid);
// echo "UPDATE post SET Title='".$Judul."'".","."Date='".$Tanggal."'".","."Contents='".$Konten."'"."WHERE Post_Id=".$postid;
// mysqli_query($con,"UPDATE post SET Title='".$Judul."'".","."Date='".$Tanggal."'".","."Contents='".$Konten."'"."WHERE Post_Id=".$postid);
// echo "UPDATE post SET Title='".$Judul."'".","."Date='".$Tanggal."'".","."Contents='".$Konten."'"."WHERE Post_Id=".$postid;
}
header("Location: index.php");
}
header("Location: index.php");
}
die();
die();
} else {
echo "Sorry, there was an error uploading your file.<br>";
}
}else{
header("Location: login.php"); /* Redirect browser */
}
......
......@@ -40,7 +40,11 @@ if (isset($_SESSION["isLogin"]) && (isset($_POST['csrf_token']) && $_POST['csrf_
} else {
if (move_uploaded_file($_FILES["image"]["tmp_name"], $target_file)) {
echo "The file ". basename( $_FILES["image"]["name"]). " has been uploaded.<br>";
<<<<<<< HEAD
$con = phpsqlconnection();
=======
$con = phpsqlconnection();
>>>>>>> df17127f283f68ad29758e0e77f1885ac2eb0ed3
$stmt = $con->prepare("INSERT INTO post (Post_Id, Creator_Id, Title, Date, Contents, Image)
VALUES (NULL,?,?,?,?,?)");
......@@ -58,12 +62,20 @@ if (isset($_SESSION["isLogin"]) && (isset($_POST['csrf_token']) && $_POST['csrf_
}
die();
<<<<<<< HEAD
} else {
echo "Sorry, there was an error uploading your file.<br>";
}
}
=======
} else {
echo "Sorry, there was an error uploading your file.<br>";
}
}
>>>>>>> df17127f283f68ad29758e0e77f1885ac2eb0ed3
}else{
header("Location: login.php"); /* Redirect browser */
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment