Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include("koneksi.php");
- if(empty($Judul) or empty ($Berita))
- {
- echo "data berita belum lengkap";
- }
- $Berita=strip_tags($Berita);
- $foto=$_FILES['foto']['name'];
- $tanggal=date("d M Y");
- $bulan=date("M");
- /*
- jangan pernah pake ini lagi.. ini tidak di rekomendasikan
- */
- $tambahData=mysql_query("insert into berita set
- judul='$Judul',
- isiBerita='$Berita',
- gambar='$foto',
- tanggal='$tanggal',
- bulan='$bulan'
- ");
- copy($HTTP_POST_FILES['foto']['tmp_name'],"image/".$_FILES['foto']['name']);
- if ($tambahData)
- {
- header("location:admin.php?p=berita&tambahBerita=ok");
- }
- else
- {
- echo "Berita gagal di input<br>";
- echo mysql_error();
- }
- /*
- /////////ini proses editnya
- <?php
- */
- /*
- //input data ke database
- //1.koneksi ke mysql
- mysql_connect("localhost","root","123456");
- //2.pilih database yang akan di pakai
- mysql_select_db("elearningsmk");
- dasar.. pake donk file koneksi.php
- */
- include("koneksi.php");
- //security
- $Berita=strip_tags($Berita);
- $foto=$_FILES['foto']['name'];
- $tanggal=date("d M Y");
- // ngak faham kenapa ada beginian? btw bulannya ketinggalan
- //3.ubah data ke dalam tabel
- $ubah=mysql_query("update berita set
- judul='$Judul',
- isiBerita='$Berita',
- gambar='$foto',
- tanggal='$tanggal',
- bulan='$bulan'
- where id=$ganti");
- copy($HTTP_POST_FILES['foto']['tmp_name'],"image/".$_FILES['foto']['name']);
- //4. mengecek keberhasilan langkah 3
- if($ubah) //if=jika
- {
- header("location:admin.php?p=berita&gantiBerita=ok");
- }
- else // selin itu
- {
- echo"data gagal di edit<br>".mysql_error();/// mysql_error===menepilkan kesalahan sql
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement