<?php
$ubah=$_GET;
$kelas=$_GET;
$angkatan=$_GET;

echo "<div class='content'>
<div class='module'>
<div class='module-head'>
<h3><a href='?page=daftar_siswa&kelas=$kelas&angkatan=$angkatan'>Siswa</a> / Ubah Siswa</h3>
</div>
<div class='module-body'>
<form action='aksiubahsiswa.php' method='post' accept-charset='utf-8' class='form-horizontal row-fluid' enctype='multipart/form-data'>";
$oke=mysql_query("SELECT * FROM siswa WHERE id_siswa='$ubah'");
$data=mysql_fetch_array($oke);
?>

<div class="control-group">
<label class="control-label">Absen <span class="text-error">*</span></label>
<div class="controls">
<input type="text" name="uabsen" class="span12" value=" <?php echo $data[3]; ?> ">
<input type="hidden" name="id_siswa" value=" <?php echo $ubah; ?> ">
<br>
</div>
</div>
<div class="control-group">
<label class="control-label">Nama <span class="text-error">*</span></label>
<div class="controls">
<input type="text" name="unama" class="span12" value=" <?php echo $data[1]; ?> ">
<br>
</div>
</div>
<div class="control-group">
<label class="control-label">Kelas <span class="text-error">*</span></label>
<div class="controls">
<input type="text" class="span12" value=" <?php echo $data[4]; ?> " disabled><input name="ukelas" type="hidden" value=" <?php echo $data[4]; ?> ">
<br>
</div>
</div>
<div class="control-group">
<label class="control-label">angkatan <span class="text-error">*</span></label>
<div class="controls">
<input type="text" class="span12" value=" <?php echo $data[5]; ?> " disabled><input name="uangkatan" type="hidden" value=" <?php echo $data[5]; ?> ">
<br>
</div>
</div>
<div class="control-group">
<label class="control-label">Foto <span class="text-error">*</span></label>
<div class="controls">
<img src="fotosiswa/<?php echo $data[2]; ?>" width="300" height="500"><br><br>
<input type="file" name="ufoto">
</div>
</div>
<div class="control-group">
<label class="control-label">Jenis Kelamin <span class="text-error">*</span></label>
<div class="controls">
<input type="radio" name="ukelamin" value="Laki-Laki" <?php if ($data[6] == 'Laki-Laki') echo 'checked="checked"'; ?> > Laki-Laki

<input type="radio" name="ukelamin" value="Perempuan" <?php if ($data[6] == 'Perempuan') echo 'checked="checked"'; ?> > Perempuan
</div>
</div>



<div class="control-group">
<label class="control-label">Tempat / Tanggal lahir <span class="text-error">*</span></label>
<div class="controls">
<select class="span2" style="width: 15%;" name="utanggal_lahir">
<option>Tanggal</option>
<option value="1" <?php if ($data[8] == '1') echo 'selected="selected"'; ?> >1</option>
<option value="2" >2</option>
<option value="3" >3</option>
<option value="4" >4</option>
<option value="5" >5</option>
<option value="6" >6</option>
<option value="7" <?php if ($data[8] == '7') echo 'selected="selected"'; ?> >7</option>
<option value="8" >8</option>
<option value="9" >9</option>
<option value="10" >10</option>
<option value="11" >11</option>
<option value="12" >12</option>
<option value="13" >13</option>
<option value="14" >14</option>
<option value="15" >15</option>
<option value="16" >16</option>
<option value="17" >17</option>
<option value="18" >18</option>
<option value="19" >19</option>
<option value="20" >20</option>
<option value="21" >21</option>
<option value="22" >22</option>
<option value="23" >23</option>
<option value="24" >24</option>
<option value="25" >25</option>
<option value="26" >26</option>
<option value="27" >27</option>
<option value="28" >28</option>
<option value="29" >29</option>
<option value="30" >30</option>
<option value="31" >31</option>
</select>
<select class="span2" style="width: 17%;" name="ubulan_lahir">
<option value="">Bulan</option>
<option value="Januari" <?php if ($data[9] == 'Januari') echo 'selected="selected"'; ?> >Januari</option>
<option value="Februari" >Februari</option>
<option value="Maret" >Maret</option>
<option value="April" >April</option>
<option value="Mei" >Mei</option>
<option value="Juni" <?php if ($data[9] == 'Juni') echo 'selected="selected"'; ?> >Juni</option>
<option value="Juli" >Juli</option>
<option value="Agustus" >Agustus</option>
<option value="September" >September</option>
<option value="Oktober" >Oktober</option>
<option value="November" >November</option>
<option value="Desember" >Desember</option>
</select>
<input type="text" name="utahun_lahir" class="span2" maxlength="4" value=" <?php echo $data[10]; ?> " placeholder="Tahun"> /
<input type="text" name="utempat_lahir" class="span5" placeholder="Tempat Lahir" value="<?php echo $data[11]; ?>">
<br>
</div>
</div>






<div class="control-group">
<label class="control-label">No.Handphone <span class="text-error">*</span></label>
<div class="controls">
<input type="text" class="span6" name="uhp" placeholder="08xxxxxxxxxx" maxlength="12" value=" <?php echo $data[11]; ?> ">
<br>
</div>
</div>


<div class="control-group">
<label class="control-label">Medsos<span class="text-error">*</span></label>
<div class="controls">
<table>
<tr>
<td>Facebook</td>
<td>:</td>
<td> <input value=" <?php echo $data[12]; ?> " type="text" class="span10" placeholder="Facebook" name="ufacebook"></td>
</tr>
<tr>
<td>BBM</td>
<td>:</td>
<td><input value=" <?php echo $data[15]; ?> " type="text" class="span10" placeholder="BBM" name="ubbm"></td>
</tr>
<tr>
<td>Line</td>
<td>:</td>
<td><input value=" <?php echo $data[14]; ?> " type="text" class="span10" placeholder="ID Line" name="uline"></td>
</tr>
<tr>
<td>Instagram</td>
<td>:</td>
<td><input value=" <?php echo $data[13]; ?> " type="text" class="span10" placeholder="Instagram" name="uinstagram"></td>
</tr>
<tr>
<td>Twitter</td>
<td>:</td>
<td><input value=" <?php echo $data[16]; ?> " type="text" class="span10" placeholder="Twitter" name="utwitter"></td>
</tr>
</table>
</div>
</div>


<div class="control-group">
<label class="control-label">Alamat <span class="text-error">*</span></label>
<div class="controls">
<input value=" <?php echo $data[17]; ?> " type="text" name="ualamat" placeholder="Alamat Rumah">
</div>
</div>

<div class="control-group">
<label class="control-label">Tentang siswa <span class="text-error">*</span></label>
<div class="controls">
<textarea name="utentang" id="konten" style="max-height:145px;min-height:145px;max-width:468px;min-width:468px;"> <?php echo $data[18]; ?> </textarea>
</div>
</div>
<div class="control-group">
<div class="controls">
<button type="submit" name="usubmit" class="btn btn-primary">Update</button>
<a href=" <?php echo "?page=daftar_siswa&kelas=$kelas&angkatan=$angkatan"; ?> " class="btn btn-default">Kembali</a>
</div>
</div>
</form>

</div>
</div>
</div> <?php


file aksiubahsiswa.php


<?php
include 'koneksi.php';
if(isset($_POST) !="" and $_POST!="" and $_POST!=""){
$uabsen=$_POST;
$unama=$_POST;
$ukelas=$_POST;
$uangkatan=$_POST;
$ukelamin=$_POST;
$utanggal_lahir=$_POST;
$ubulan_lahir=$_POST;
$utahun_lahir=$_POST;
$utempat_lahir=$_POST;
$uhp=$_POST;
$ufacebook=$_POST;
$ubbm=$_POST;
$uline=$_POST;
$uinstagram=$_POST;
$utwitter=$_POST;
$ualamat=$_POST;
$utentang=$_POST;
$uid=$_POST;
$ufoto = $_POST;
$lokasi_file = $_FILES;
$tipe_file = $_FILES;
$nama_file = $_FILES;
echo $nama_file;
if (!empty($lokasi_file)) {
$acak = rand(1,99);
$uunik = $acak.$unama.'_'.$nama_file;
move_uploaded_file($lokasi_file,'fotosiswa/'.$uunik);

$sql=mysql_query("UPDATE siswa SET nama_siswa='$unama',absen_siswa='$uabsen',kelas_siswa='$ukelas',angkatan_siswa='$uangkatan',kelamin_siswa='$ukelamin',tanggal_lahir='$utanggal_lahir',bulan_lahir='$ubulan_lahir',tahun_lahir='$utahun_lahir',tempat_lahir='$utempat_lahir',no_hp='$uhp',facebook_siswa='$ufacebook',bbm_siswa='$ubbm',line_siswa='$uline',instagram_siswa='$uinstagram',twitter_siswa='$utwitter',alamat_siswa='$ualamat',tentang='$utentang' WHERE id_siswa='$uid'");
mysql_query($sql);
header("location:home.php?page=daftar_siswa&kelas=$ukelas&angkatan=$uangkatan&info=update siswa berhasil");

}
}
?>
Silahkan login untuk menjawab!