<?php
$sqlView=mysql_query("select * from artikel where id='".$_GET['id']."'");
$data=mysql_fetch_array($sqlView);
?>
<div class="panel panel-default">
<div class="panel-heading">
<font size="+2">Edit Artikel</font>
</div>
<div class="panel-body">
<?php
if (isset($_POST['simpan']))
{
if ($_FILES['logo']['name']!="")
{
$tempValue = $_FILES["logo"];
$path="../";
$input_field="logo";
include("../include/images_processing.php");
unlink("../thumbnails/".$_POST["picOld"].".jpg");
unlink("../uploaded_images/".$_POST["picOld"].".jpg");
}
$sqlSimpan=mysql_query("update artikel set title='".$_POST['title']."',html='".$_POST['html']."',logo='".($_FILES['logo']['name']!=""?$i_random:$_POST['picOld'])."',active='".$_POST['active']."',fb='".$_POST['fb']."',form='".$_POST['form']."' where id='".$_POST['id']."' ");
if ($sqlSimpan)
{
echo "<div class=\"alert alert-success\"><i class=\"fa fa-check-square\"></i> Artikel berhasil disimpan!! <a href=\"index.php?page=artikel\" class=\"btn btn-info btn-sm\">Lanjutkan</a></div>";
}
}
else {
?>
<form action="<?php $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">
<input type="hidden" name="id" value="<?php echo $_GET['id']; ?>">
<input type="hidden" name="picOld" value="<?php echo $data['logo']; ?>">
<b>Judul</b>
<input type="text" required name="title" class="form-control" value="<?php echo $data['title']; ?>">
<br>
<b>Isi Artikel</b>
<textarea name="html" required class="form-control"><?php echo $data['html']; ?></textarea>
<br>
<b>Logo</b>
<input type="file" name="logo" id="logo" />
<br>
<b>Komentar Facebook</b>
<select name="fb" class="form-control">
<option <?php echo ($data['fb']==1?"selected":""); ?> value="1">YES</option>
<option <?php echo ($data['fb']==0?"selected":""); ?> value="0">NO</option>
</select>
<br>
<b>Form Pertanyaan</b>
<select name="form" class="form-control">
<option <?php echo ($data['form']==1?"selected":""); ?> value="1">YES</option>
<option <?php echo ($data['form']==0?"selected":""); ?> value="0">NO</option>
</select>
<br>
<b>Aktif</b>
<select name="active" class="form-control">
<option <?php echo ($data['active']==1?"selected":""); ?> value="1">YES</option>
<option <?php echo ($data['active']==0?"selected":""); ?> value="0">NO</option>
</select>
<br>
<input type="submit" name="simpan" value="Simpan" class="btn btn-primary btn-block no_radius">
</form>
<?php } ?>
</div>
</div>