Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* aksipengumuman.php */
- function ubahTgl($tanggal)
- {
- $tanggalan = explode('/',$tanggal);
- $array = array($tanggalan[2],$tanggalan[1],$tanggalan[0]);
- $return = implode('-',$array);
- return $return;
- }
- //mulai proses
- $tgl = ubahTgl($_POST[tgl]);
- $namafile = "";
- /*
- cek ada gambar tidak
- asumsi saya, bisa isi data acara dan gambar, kl ada gambar ya di-save juga gambarnya, kalau gak ada ya di-save aja isian acaranya
- */
- if (isset($_FILES['file_user'])){
- $file_user = $_FILES[ 'file_user'][ 'tmp_name'];
- $namafile = $_FILES[ 'file_user'][ 'name'];
- $tujuan = "C:\\xampp\\htdocs\\images\\" . $namafile;
- move($file_user, $tujuan);
- //print keterangan
- echo "<h3>Proses upload gambar berhasil !</h3>";
- echo "$namafile ";
- echo "di simpan di: $tujuan<br />";
- }
- //masukkin ke database
- mysql_connect("localhost","root","");
- mysql_select_db("pintar");
- $query=mysql_query("INSERT INTO pengumuman(acara, tgl, tempat, keterangan, gambar) VALUES('$_POST["acara"]', '$tgl', '$_POST["tempat"]', '$_POST["keterangan"]' , '$namafile')");
- if ($query){
- echo "<h3>Pengumuman Berhasil Disimpan di database.</h3>";
- }else{
- echo "<h3>Pengumuman Gagal Disimpan di database.</h3>";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement