return false;} };
}; script
div
1.5 edit.php
?php include incheader.php; ? ?php
if isset_GET[judul] { judul_q = _GET[judul];
} if isset_POST[submit] {
judul = _POST[judul]; pembuat = _POST[pembuat];
keterangan = _POST[keterangan]; waktu = _POST[tanggal];
imgFile = _FILES[gambar][name]; tmp_dir = _FILES[gambar][tmp_name];
imgSize = _FILES[gambar][size]; if emptyjudul {
errMSG = Masukkan judul.; } else if emptyketerangan {
errMSG = Masukkan keterangan.; } else if emptyimgFile {
query2 = mysqli_querykon, UPDATE berita SET judul=judul,
keterangan=keterangan WHERE judul=judul_q;
if query2 { ?
script
Universitas Sumatera Utara
alertData berhasil di update;
window.location.href = index.php?berita;
script ?php
} else { echo Error.. .
mysqli_errorkon; } } else {
upload_dir = ..foto_berita; imgExt = strtolowerpathinfoimgFile,
PATHINFO_EXTENSION; valid_extensions = arrayjpeg,
jpg, png, gif; userpic = rand1000, 1000000 . . .
imgExt; if in_arrayimgExt,
valid_extensions { if imgSize 500000000000 {
move_uploaded_filetmp_dir, upload_dir . userpic;
} else { errMSG = Maaf, file terlalu
besar.; }
} else { errMSG = Hanya tipe JPG, JPEG,
PNG GIF yang diizinkan.; }
if isseterrMsg { query2 = mysqli_querykon,
UPDATE berita SET judul=judul,
Universitas Sumatera Utara
keterangan=keterangan, gambar=userpic WHERE judul=judul_q;
if query2 { ?
script alertData berhasil di
update; window.location.href = index.php?berita;
script ?php
} else { echo Error.. .
mysqli_errorkon; }
} else { ?
script alert?php echo errMSG;
?; script
?php } }}?
section id=section div class=section-container
?php query = mysqli_querykon, SELECT
FROM berita WHERE judul=judul_q; row = mysqli_fetch_arrayquery;
? form class=form-horizontal
role=form action= method=post enctype=multipartform-data
?php
Universitas Sumatera Utara
if isseterrMSG { ?
div ?php echo errMSG; ?
div ?php
} ?
fieldset -- Form Name --
legendBeritalegend div class=form-group
label class=col-md-4 control-label for=judulJudullabel
div class=col-md-6 input value=?php
echo row[judul]; ? id=textinput name=judul type=text placeholder=
class=form-control input-md required=true
div div
div class=form-group label class=col-md-4
control-label for=pembuatPembuatlabel div class=col-md-6
input value=?php echo row[pembuat]; ? id=textinput
name=pembuat type=text placeholder= class=form-control input-md required=true
div
Universitas Sumatera Utara
div div class=form-group
label class=col-md-4 control-label for=tanggalWaktulabel
div class=col-md-6 input value=?php
echo row[tanggal]; ? id=textinput name=tanggal type=text placeholder=
class=form-control input-md required=true
div div
-- Textarea -- div class=form-group
label class=col-md-4 control-label
for=keteranganKeteranganlabel div class=col-md-6
textarea rows=10 class=form-control id=keterangan
name=keterangan?php echo row[keterangan]; ?textarea
div div
-- Text input-- div class=form-group
label class=col-md-4 control-label for=label
div class=col-md-4 img class=img-
thumbnail src=..foto_berita?php echo row[gambar]; ?
div
Universitas Sumatera Utara
div -- File Button --
div class=form-group label class=col-md-4
control-label for=gambarGambarlabel div class=col-md-4
input id=gambar name=gambar class=input-file type=file
div div
div class=form-group label class=col-md-4
control-label for=label div class=col-md-4
input id=submit name=submit class=input-submit
type=submit div div fieldset
form divsection
?php include incfooter.php; ?
1.6 tambahberita.php