Advertisement
GWibisono

berantakan yg ptg jelas

Nov 12th, 2013
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.59 KB | None | 0 0
  1. <?php
  2. include("koneksi.php");
  3. if(empty($Judul) or empty ($Berita))
  4. {
  5.     echo "data berita belum lengkap";
  6. }
  7.  
  8. $Berita=strip_tags($Berita);
  9.  
  10. $foto=$_FILES['foto']['name'];
  11.  
  12. $tanggal=date("d M Y");
  13.  
  14. $bulan=date("M");
  15. /*
  16. jangan pernah pake ini lagi.. ini tidak di rekomendasikan
  17. */
  18. $tambahData=mysql_query("insert into berita set
  19. judul='$Judul',
  20. isiBerita='$Berita',
  21. gambar='$foto',
  22. tanggal='$tanggal',
  23. bulan='$bulan'
  24. ");
  25.  
  26. copy($HTTP_POST_FILES['foto']['tmp_name'],"image/".$_FILES['foto']['name']);
  27. if ($tambahData)
  28. {
  29.     header("location:admin.php?p=berita&tambahBerita=ok");
  30. }
  31. else
  32. {
  33.     echo "Berita gagal di input<br>";
  34.     echo mysql_error();
  35. }
  36.  
  37. /*
  38. /////////ini proses editnya
  39.  
  40. <?php
  41. */
  42. /*
  43.     //input data ke database
  44.     //1.koneksi ke mysql
  45.     mysql_connect("localhost","root","123456");
  46.  
  47.     //2.pilih database yang akan di pakai
  48.     mysql_select_db("elearningsmk");
  49.  
  50. dasar.. pake donk file koneksi.php
  51. */
  52. include("koneksi.php");
  53. //security
  54. $Berita=strip_tags($Berita);
  55. $foto=$_FILES['foto']['name'];
  56. $tanggal=date("d M Y");
  57. // ngak faham kenapa ada beginian? btw bulannya ketinggalan
  58.  
  59. //3.ubah data ke dalam tabel
  60. $ubah=mysql_query("update berita set
  61. judul='$Judul',
  62. isiBerita='$Berita',
  63. gambar='$foto',
  64. tanggal='$tanggal',
  65. bulan='$bulan'
  66. where id=$ganti");
  67.  
  68. copy($HTTP_POST_FILES['foto']['tmp_name'],"image/".$_FILES['foto']['name']);
  69.  
  70. //4. mengecek keberhasilan langkah 3
  71. if($ubah) //if=jika
  72. {
  73.     header("location:admin.php?p=berita&gantiBerita=ok");
  74. }
  75. else // selin itu
  76. {
  77.     echo"data gagal di edit<br>".mysql_error();/// mysql_error===menepilkan kesalahan sql
  78. }
  79. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement