upload foto gagal

Robert James M · Sep 25, 2012
mas mau tanya lagi kan sudah buat seperti ini

ini databasenya

nama_perusahaan,alamat,telephone, fax, email, website, kontak_person, npwp, tanggal_pengukuhan, photo
<form class="block-content form" action="add_company_profile.php" method="post">

    <h1>Company Profile<a href="http://localhost/ABMS/halaman_master.php"><img src="images/icons/fugue/navigation-180.png" width="16" height="16"> Back</a></h1>



    <div class="block-header">Register New Tenant</div>

    <div class="columns">

        <div class="colx2-left">

            <fieldset>

                <legend>Profile</legend>



                <table cellpadding="3" class="table-padding">

                    <tr title="Required">
                        <td><b>Company Name</b><span class="required">*</span></td>
                        <td>:</td>
                        <td><input type="text" name="nama_perusahaan" validation="isNotEmpty" title="Full name" style="width:300px" value="" /></td>
                    </tr>
                    <tr title="Required">
                        <td><b>Address</b><span class="required">*</span></td>
                        <td>:</td>
                        <td><input type="text" name="alamat" validation="isNotEmpty" title="Full name" style="width:300px" value="" /></td>
                    </tr>
                    <tr title="Required">
                        <td><b>Email</b><span class="required">*</span></td>
                        <td>:</td>
                        <td><input type="text" name="email" validation="isNotEmpty" title="Full name" style="width:300px" value="" /></td>
                    </tr>
                    <tr title="Required">
                        <td><b>Website</b><span class="required">*</span></td>
                        <td>:</td>
                        <td><input type="text" name="website" validation="isNotEmpty" title="Full name" style="width:300px" value="" /></td>
                    </tr>
                </table>
            </fieldset>

             <fieldset>

                <legend>Important</legend>

                <table cellpadding="3" class="table-padding">
                    <tr title="Required">
                        <td><b>NPWP</b><span class="required">*</span></td>
                        <td>:</td>
                        <td><input type="text" name="npwp" validation="isNotEmpty" title="Full name" style="width:300px" value="" /></td>
                    </tr>
                    <tr title="Required">
                        <td><b>Tanggal Pengukuhan</b><span class="required">*</span></td>
                        <td>:</td>
                        <td><input type="text" name="tanggal_pengukuhan" validation="isNotEmpty" title="Full name" style="width:300px" value="" /></td>
                    </tr>

                </table>

            </fieldset>

        </div>

        <div class="colx2-right">

            <fieldset>

                <legend>Number</legend>

                <table cellpadding="3" class="table-padding">

                    <tr>
                        <td><b>Telephone</b></td>
                        <td>:</td>
                        <td><input type="text" name="telephone" value="" /></td>
                    </tr>
                    <tr>
                        <td><b>Fax</b></td>
                        <td>:</td>
                        <td><input type="text" name="fax" value="" /></td>
                    </tr>
                    <tr>
                        <td><b>Contact Person</b></td>
                        <td>:</td>
                        <td><input type="text" name="kontak_person" value="" /></td>
                    </tr>
                </table>
            </fieldset>
            <fieldset>

                <legend>Logo</legend>

                <table cellpadding="3" class="table-padding">

                    <tr>
                        <td><b>Logo</b></td>
                        <td>:</td>
                        <td><input type="hidden" name="MAX_FILE_SIZE" value = "800000" />
                        <br>
                            <input name="photo" type="file" id="photo" size="30" /></td>
                    </tr>
                   
                </table>
            </fieldset>

        </div>

    </div>

    <div class="block-footer" style="height:30px;">

        &nbsp;

        <div class="float-right">

            <button type="submit"><img src="images/icons/fugue/tick-octagon.png" width="16" height="16"> Save</button>

            <button type="reset" class="grey" onclick="this.form.reset();"><img src="images/icons/fugue/arrow-circle.png" width="16" height="16"> Reset</button>

            <button type="reset" class="red" onclick="document.location.href='http://localhost/jadi/tenant.php';"><img src="images/icons/fugue/cross-white.png" width="16" height="16"> Cancel</button>

        </div>

    </div>



</form>

nah ini prosesnya
<?php

  mysql_connect   ("localhost", "root", "rahasia");
  mysql_select_db ("abms");
  
  
  $nama       	= htmlspecialchars($_POST['nama_perusahaan']);
  $alamat     	= htmlspecialchars($_POST['alamat']);
  $tlp        	= htmlspecialchars($_POST['telephone']);
  $fax        	= htmlspecialchars($_POST['fax']);
  $email      	= htmlspecialchars($_POST['email']);
  $website    	= htmlspecialchars($_POST['website']);
  $kontak		    = htmlspecialchars($_POST['kontak_person']);
  $npwp         = htmlspecialchars($_POST['npwp']);
  $tgl          = htmlspecialchars($_POST['tanggal_pengukuhan']);
  
    if (empty($nama))
    {die ("isikan nama perusahaan");}
    elseif (empty($npwp)) 
    {die ("isikan nomor npwp");}
    else 
    {
      $cekdata  = "select nama_perusahaan from company_profile where nama_perusahaan='$nama'";
      $ada      = mysql_query($cekdata) or die(mysql_error());
      
      if(mysql_num_rows($ada)>0)
      {die ("nama telah terdaftar");}
      
      else  {
      
        if (!empty($_FILES['photo']["tmp_name"]))
        {
        
        $namafolder   = "photo/";
        $jenis_gambar = $_FILES['photo']['type'];
        if ($jenis_gambar=="image/jpeg" || $jenis_gambar=="image/jpg" || $jenis_gambar=="image/gif"  || $jenis_gambar=="image/png")
      
         {
          $photo  = $namafolder . basename($_FILES['photo']['name']);
          if  (!move_uploaded_file($_FILES['photo']['tmp_name'], $photo))
            { die("Gambar gagal dikirim"); }
         
         } else { die("Jenis gambar yang anda kirim salah. Harus .jpg .gif .png"); }
         
    }
        mysql_query ("insert into company_profile values('$nama','$alamat','$tlp','$fax','$email','$website','$kontak','$npwp','$tgl','$photo') ");
        echo  "<h1>Berhasil</h1>";
        echo  "<br>";
      
    }
    } 
  
   
  
?>    

field lain masuk ke databasenya cuma yang photo tidak muncul error Notice: Undefined variable: photo in C:\xampp\htdocs\ABMS\add_company_profile.php on line 166

saya udah ulang ketik dan cek prosesnya ko tetap salah ya?

terima kasih
Silahkan login untuk menjawab!
0
Loading...
Ellyx Christian · Sep 25, 2012 · 0 Suka · 0 Tidak Suka
tinggal di formnya ditambahkan enctype="multipart/form-data"
seperti
<form class="block-content form" action="add_company_profile.php" method="post" enctype="multipart/form-data">
0
Loading...
Robert James M · Sep 26, 2012 · 0 Suka · 0 Tidak Suka
oh iya,,, kelupaan. makasih mas