Gagal update data

k1dc00l · Aug 8, 2011
<?php
include("lib_func.php");
?>

<?php
if($_FILES==0){
$link=koneksi_db();
$jenis_surat=$_POST;
$index=$_POST;
$pengirim=$_POST;
$no_surat=$_POST;
$tanggal_surat=$_POST;
$kode=$_POST;
$perihal=$_POST;
$lampiran=$_POST;
$isi_ringkasan=$_POST;
$pengolah=$_POST;
$tanggal_diteruskan=$_POST;
$tanda_terima=$_POST;
$photo=$_FILES;
$namafilebaru="scan/".$photo;
if(move_uploaded_file($_FILES,$namafilebaru)==true)

$sql="UPDATE surat_masuk set `jenis_surat`='$jenis_surat',`index`='$index',`pengirim`='$pengirim',`no_surat`='$no_surat',`tanggal_surat`='$tanggal_surat',`kode`='$kode',`perihal`='$perihal',`lampiran`='$lampiran',`isi_ringkasan`='$isi_ringkasan',`pengolah`='$pengolah',`tanggal_diteruskan`='$tanggal_diteruskan',`tanda_terima`='$tanda_terima',`photo`='$photo' WHERE `no_urut`= '$no_urut'";
$res=mysql_query($sql);
if($res){
header("Location:inputsuccess.php");
}
else{
echo "Data produk baru gagal disimpan dengan kesalahan ".mysql_error();
}
}
?>





Saya mau nanya, script edit di atas kenapa error yah??
berikut pesan errornya:



Notice: Undefined index: filegambar in C:\wamp\www\New folder (2)\eletters++ - Copy\updateprogress.php on line 6

Notice: Undefined index: filegambar in C:\wamp\www\New folder (2)\eletters++ - Copy\updateprogress.php on line 20

Notice: Undefined index: filegambar in C:\wamp\www\New folder (2)\eletters++ - Copy\updateprogress.php on line 22

otice: Undefined variable: sql in C:\wamp\www\New folder (2)\eletters++ - Copy\updateprogress.php on line 25



mohon pencerahannya.. :)
Silahkan login untuk menjawab!
0
Loading...
k1dc00l · Aug 8, 2011 · 0 Suka · 0 Tidak Suka
maav mas kurang ngerti jadi yg perlu di tambahin tu //tepatgambar => nama folder tempat meletakkan gambar yg di move dari folder temporari. di simpan dimana???
1
Loading...
Efriey · Aug 8, 2011 · 1 Suka · 0 Tidak Suka
Kalau dilihat secara sekilas script diatas kayaknya ada yg kurang dibagian
if(move_uploaded_file($_FILES['filegambar']['tmp_name'],$namafilebaru)==true)

kode diatas tidak menjelaskan ke script dimana gambar akan dipindahkan.
coba lengkapi script tsb menjadi seperti berikut
if(move_uploaded_file($_FILES['filegambar']['tmp_name'],'tempatgambar/$namafilebaru')==true) //tepatgambar => nama folder tempat meletakkan gambar yg di move dari folder temporari.

oya, sekalian lengkapi tuh script nya kurang kurung kurawal tuh pas posting pertanyaan :)
0
Loading...
Efriey · Aug 8, 2011 · 0 Suka · 0 Tidak Suka
hehe, td salah ketik mas... 'tempatgambar/$namafilebaru'
0
Loading...
Efriey · Aug 8, 2011 · 0 Suka · 0 Tidak Suka
gini mas...itu script update kan?
alurnya kurang lebih script akan merubah data di database serta akan meletakkan gambar di fodler yang sudah disediakan kan...?
Nah, pada kondisi ini script move_uploaded_file($_FILES,'tempatgambar/$namafilebaru' akan memindahkan gambar yg di upload ke dalam folder 'tempatgambar' ...
dan pastikan juga foldernya sudah dibuat...
0
Loading...
Ellyx Christian · Aug 8, 2011 · 0 Suka · 0 Tidak Suka
0
Loading...
k1dc00l · Aug 9, 2011 · 0 Suka · 0 Tidak Suka
mas efriey dan mas christ sudah tidak ada error namun gambar tidak dapat terupdate
berikut kode nya mas-mas
<?php
include("lib_func.php");
?>

<?php
if($_FILES['filegambar']['error']==0){
	$link=koneksi_db();
	$no_urut=$_POST['no_urut'];
	$jenis_surat=$_POST['jenis_surat'];
	$index=$_POST['index'];
	$pengirim=$_POST['pengirim'];
	$no_surat=$_POST['no_surat'];
	$tanggal_surat=$_POST['tanggal_surat'];
	$kode=$_POST['kode'];
	$perihal=$_POST['perihal'];
	$lampiran=$_POST['lampiran'];
	$isi_ringkasan=$_POST['isi_ringkasan'];
	$pengolah=$_POST['pengolah'];
	$diteruskan_kepada=$_POST['diteruskan_kepada'];
	$tanggal_diteruskan=$_POST['tanggal_diteruskan'];
	$tanda_terima=$_POST['tanda_terima'];
	$photo=$_FILES['filegambar']['name'];
		$namafilebaru="scan/".$photo;
		if(move_uploaded_file($_FILES['filegambar']['tmp_name'],
		                      $namafilebaru)==true)
							  
	$sql="UPDATE surat_masuk set 
	`jenis_surat`='$jenis_surat',
	`index`='$index',
	`pengirim`='$pengirim',
	`no_surat`='$no_surat',
	`tanggal_surat`='$tanggal_surat',
	`kode`='$kode',
	`perihal`='$perihal',
	`lampiran`='$lampiran',
	`isi_ringkasan`='$isi_ringkasan',
	`pengolah`='$pengolah',
	`tanggal_diteruskan`='$tanggal_diteruskan',
	`tanda_terima`='$tanda_terima',
	`photo`='$photo' 
	WHERE `no_urut`= '$no_urut'";
 			mysql_query($sql);
				header("Location:inputsuccess.php");
			}		
			else{
				echo "Data produk baru gagal disimpan dengan kesalahan ".mysql_error();
				}
?>
0
Loading...
Ellyx Christian · Aug 9, 2011 · 0 Suka · 0 Tidak Suka
saya minta kode html form yang kamu gunakan untuk update? yang seperti <form name="form" method="post">
0
Loading...
k1dc00l · Aug 9, 2011 · 0 Suka · 0 Tidak Suka
ou ini mas christ kode update_lettersin.php dan yg diatas updateprogress.php...
<?php
	session_start();
	if(isset($_SESSION['sudahlogin']))
	{
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"[]>
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US" xml:lang="en">
<head>
<?php 
	include("lib_func.php");
?>

    <!--
    Base template (without user's data) checked by http://validator.w3.org : "This page is valid XHTML 1.0 Transitional"
    -->
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>E-Letters</title>
    <meta name="description" content="Description" />
    <meta name="keywords" content="Keywords" />


    <link rel="stylesheet" href="style.css" type="text/css" media="screen" />
    <!--[if IE 6]><link rel="stylesheet" href="style.ie6.css" type="text/css" media="screen" /><![endif]-->
    <!--[if IE 7]><link rel="stylesheet" href="style.ie7.css" type="text/css" media="screen" /><![endif]-->
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
    <script type="text/javascript" src="jquery.js"></script>
    <script type="text/javascript" src="script.js"></script>
</head>
<body>
<div id="art-page-background-glare">
    <div id="art-page-background-glare-image"> </div>
</div>
<div id="art-main">
    <div class="art-header">
    <div class="art-header-wrapper">
    <div class="art-header-inner">
        <div class="art-logo">
                 <h1 class="art-logo-name"><a href="menu_admin.php">E-letters</a></h1>
                         <h2 class="art-logo-text">aplikasi surat digital bkd</h2>
      </div>
    </div>
    </div>
    </div>
    <div class="cleared reset-box"></div>
    <div class="art-sheet">
        <div class="art-sheet-tl"></div>
        <div class="art-sheet-tr"></div>
        <div class="art-sheet-bl"></div>
        <div class="art-sheet-br"></div>
        <div class="art-sheet-tc"></div>
        <div class="art-sheet-bc"></div>
        <div class="art-sheet-cl"></div>
        <div class="art-sheet-cr"></div>
        <div class="art-sheet-cc"></div>
        <div class="art-sheet-body">
<div class="art-nav">
<div class="art-nav-outer">
	<ul class="art-hmenu">
			<div><font size="3">Selamat datang, <?php echo $_SESSION['jabatan']; ?></font></div>
	</ul>
</div>
</div>
<div class="cleared reset-box"></div>
<div class="art-content-layout">
                <div class="art-content-layout-row">
                    <div class="art-layout-cell art-sidebar1">
<div class="art-block">
    <div class="art-block-body">
                <div class="art-blockheader">
                    <div class="l"></div>
                    <div class="r"></div>
                    <h3 class="t">SURAT MASUK</h3>
                </div>
                <div class="art-blockcontent">
                    <div class="art-blockcontent-tl"></div>
                    <div class="art-blockcontent-tr"></div>
                    <div class="art-blockcontent-bl"></div>
                    <div class="art-blockcontent-br"></div>
                    <div class="art-blockcontent-tc"></div>
                    <div class="art-blockcontent-bc"></div>
                    <div class="art-blockcontent-cl"></div>
                    <div class="art-blockcontent-cr"></div>
                    <div class="art-blockcontent-cc"></div>
                    <div class="art-blockcontent-body">

<div>
<p class="menu_list"><a href="menu_admin.php"><b>Buat Surat Masuk</b></a></p>
</div>

<div>
<p class="menu_list"><a href="view_lettersin.php"><b>Lihat Surat Masuk</b></a></p>
</div>

<div>
<p class="menu_list"><a href="detailupdate_lettersin.php"><b>Edit Surat Masuk</b></a></p>
</div>
                                		<div class="cleared"></div>
                    </div>
                </div>
		<div class="cleared"></div>
    </div>
    
    <div class="art-block-body">
                <div class="art-blockheader">
                    <div class="l"></div>
                    <div class="r"></div>
                    <h3 class="t">SURAT keluar</h3>
                </div>
                <div class="art-blockcontent">
                    <div class="art-blockcontent-tl"></div>
                    <div class="art-blockcontent-tr"></div>
                    <div class="art-blockcontent-bl"></div>
                    <div class="art-blockcontent-br"></div>
                    <div class="art-blockcontent-tc"></div>
                    <div class="art-blockcontent-bc"></div>
                    <div class="art-blockcontent-cl"></div>
                    <div class="art-blockcontent-cr"></div>
                    <div class="art-blockcontent-cc"></div>
                    <div class="art-blockcontent-body">

<div>
<p class="menu_list"><a href="maintenance.php"><b>Buat Surat Keluar</b></a></p>
</div>
 
<div>
<p class="menu_list"><a href="maintenance.php"><b>Lihat Surat Keluar</b></a></p>
</div> 
                                		<div class="cleared"></div>
                    </div>
                </div>
		<div class="cleared"></div>
    </div>
    
       <div class="art-block-body">
                <div class="art-blockheader">
                    <div class="l"></div>
                    <div class="r"></div>
                    <h3 class="t"><a href="search.php">Cari</a></h3>
                </div>
                <div class="art-blockcontent">
                    <div class="art-blockcontent-tl"></div>
                    <div class="art-blockcontent-tr"></div>
                    <div class="art-blockcontent-bl"></div>
                    <div class="art-blockcontent-br"></div>
                    <div class="art-blockcontent-tc"></div>
                    <div class="art-blockcontent-bc"></div>
                    <div class="art-blockcontent-cl"></div>
                    <div class="art-blockcontent-cr"></div>
                  <div class="art-blockcontent-cc"></div>
                </div>
    </div>
    
    <div class="art-block-body">
                <div class="art-blockheader">
                    <div class="l"></div>
                    <div class="r"></div>
                    <h3 class="t"><a href="logout.php">LOGOUT</a></h3>
                </div>
                <div class="art-blockcontent">
                    <div class="art-blockcontent-tl"></div>
                    <div class="art-blockcontent-tr"></div>
                    <div class="art-blockcontent-bl"></div>
                    <div class="art-blockcontent-br"></div>
                    <div class="art-blockcontent-tc"></div>
                    <div class="art-blockcontent-bc"></div>
                    <div class="art-blockcontent-cl"></div>
                    <div class="art-blockcontent-cr"></div>
                  <div class="art-blockcontent-cc"></div>
                </div>
    </div>
    
</div>

                      <div class="cleared"></div>
                    </div>
                    <div class="art-layout-cell art-content">
<div class="art-post">
    <div class="art-post-body">
<div class="art-post-inner art-article">
                                <h2 class="art-postheader">
                <img src="./images/favicon.ico" width="23" height="25" alt="" />Edit Surat Masuk
                                </h2>
                                <div class="cleared"></div>
                                                <div class="art-postcontent">

<p>
<?php
	$no_urut = $_REQUEST['no_urut'];
	$link=koneksi_db();
	$sql="SELECT * FROM
	      surat_masuk where `no_urut` = '$no_urut'
 	      ORDER BY no_urut"; 
	$res=mysql_query($sql,$link) or die(mysql_error()); 
	
	?>
    
    <?php

	$i=0;
	while($data=mysql_fetch_array($res)){
	
	
		?> 
<form action="updateprogress.php" method="post">
<table border=0 width="100%"  bgcolor="WHITE" align="center">
			<tr>
			  <td colspan=4 align="center" bgcolor="#CCCCCC">&nbsp;</td>
			</tr>
			<tr>
			  <td width="20%">No Urut </td>
			  <td width="1%">:</td>
			  <td width="50%"><input type="text" class="tb2" name="no_urut" value="<?php $i++; echo $data['no_urut']; ?>" readonly/></td>
			  <td colspan="1" style="border:solid 1px;" rowspan="10"><img src="scan/<?php echo $data['photo']; ?>" width="200" height="250" border="0"/></td>

			<tr>
			  <td>Jenis Surat </td>
			  <td>:</td>
			  <td><select name="jenis_surat" class="tb2">
              <option value="<?php $i++; echo $data['jenis_surat']; ?>"><?php $i++; echo $data['jenis_surat']; ?></option>
			    <option value="Sangat Rahasia">Sangat Rahasia</option>
                  <option value="Rahasia">Rahasia</option>
                  <option value="Umum">Umum</option>
              </select></td>
  </tr>
			<tr>
			  <td>No Surat </td>
			  <td>:</td>
			  <td><input type="text" class="tb2" name="no_surat" value="<?php $i++; echo $data['no_surat']; ?>" /></td>
		  </tr>
			<tr>
			  <td>Kode Surat</td>
			  <td>:</td>
			  <td><input type="text" class="tb2"  name="kode" value="<?php $i++; echo $data['kode']; ?>" /></td>
  </tr>
			<tr>
			  <td>Index</td>
			  <td>:</td>
			  <td><input type="text" class="tb2"  name="index" value="<?php $i++; echo $data['index']; ?>" /></td>
			</tr>
			<tr>
			  <td>Perihal</td>
			  <td>:</td>
			  <td><input type="text" class="tb2"  name="perihal" value="<?php $i++; echo $data['perihal']; ?>" /></td>
			</tr>
			<tr>
		    <td>Isi Ringkas</td>
		    <td>:</td>
		    <td><input type="text" class="tb2"  name="isi_ringkasan" value="<?php $i++; echo $data['isi_ringkasan']; ?>" /></td>
			</tr>
			<tr>
			  <td>Pengirim</td>
			  <td>:</td>
			  <td><input type="text" class="tb2"  name="pengirim" value="<?php $i++; echo $data['pengirim']; ?>" /></td></tr>
			<tr>
			  <td>Tanggal Surat </td>
			  <td>:</td>
			  <td><input type="text" class="tb2"  name="tanggal_surat" value="<?php $i++; echo $data['tanggal_surat']; ?>" /></td>
</tr>
			
			<tr>
			  <td>Lampiran</td>
			  <td>:</td>
			  <td><select name="lampiran" class="tb2" >
			   <option value="<?php $i++; echo $data['lampiran']; ?>"><?php $i++; echo $data['lampiran']; ?></option><option value="0">-</option><?php
	 for($a=1;$a<101;$a++){
		 echo ('<option value='.$a.'>'.$a.' </option>');
	 }
     ?>
       </select></td>
  </tr>
			<tr>
			  <td>Pengolah</td>
			  <td>:</td>
			  <td><input type="text" class="tb2"  name="pengolah" value="<?php $i++; echo $data['pengolah']; ?>" />
			  <td><input type="file" name="filegambar1" class="tb2"/>
              </td></td>
  </tr>
			<tr>
			  <td>Tanggal diteruskan </td>
			  <td>:</td>
			  <td><input type="text" class="tb2"  name="tanggal_diteruskan" value="<?php $i++; echo $data['tanggal_diteruskan']; ?>" /></td>
  </tr>
			<tr>
			  <td>Tanda terima </td>
			  <td>:</td>
			  <td><select name="tanda_terima" class="tb2">
                   <option value="<?php $i++; echo $data['tanda_terima']; ?>"><?php $i++; echo $data['tanda_terima']; ?></option>
                   <option value="Ya">Ya</option>
                  <option value="Tidak">Tidak</option>
                </select></td>
</tr>
			<tr>
			  <td colspan="5" bgcolor="#CCCCCC"><center><input type="submit" name="btn_submit2" value="Buat">
			    <input type="reset" name="reset" value="Batal"></</td>
		  </tr>
		</table>
		</tr>
  <?php } ?>
</p>

                </div>
                <div class="cleared"></div>
                </div>

		<div class="cleared"></div>
    </div>
</div>

                      <div class="cleared"></div>
                    </div>
                </div>
            </div>
            <div class="cleared"></div>
            <div class="art-footer">
                <div class="art-footer-t"></div>
                <div class="art-footer-b"></div>
                <div class="art-footer-body">
                            <div class="art-footer-text">
                                
<p>Copyright of API Team © 2011. All Rights Reserved.</p>


                  </div>
                    <div class="cleared"></div>
                </div>
            </div>
    		<div class="cleared"></div>
        </div>
    </div>
    <div class="cleared"></div>
</div>

</body>
</html>

<?php
	}
	else
		header("Location:loginfailure.php");
?>
0
Loading...
Ellyx Christian · Aug 9, 2011 · 0 Suka · 0 Tidak Suka
kamu salah membuat formnya, baris ke 205:
<form action="updateprogress.php" method="post">
seharusnya:
<form action="updateprogress.php" method="post" enctype="multipart/form-data">
agar file bisa terupload kamu harus tambahkan enctype="multipart/form-data" pada form kamu.
0
Loading...
k1dc00l · Aug 9, 2011 · 0 Suka · 0 Tidak Suka
sip terima kasih mas christ atas semua ilmunya dan bantuannya,,,,