Pages

October 24, 2013

Membuat Edit & Update Siswa dengan PHP







Nama File  :  edit_siswa.php


  <form name="form1" method="post" action="update_siswa.php"> 
      <table width="400" border="0" align="center" cellpadding="1" cellspacing="1" bordercolor="#FFFF99" bgcolor="#FF0000"> 
        <tr bgcolor="#FFFFCC"> 
          <td height="50" colspan="2"><div align="center">EDIT DATA</div></td> 
        </tr> 
     <?php 
      mysql_connect('localhost','root','root'); 
      mysql_select_db('sisfokol'); 
       
      $sqlTampil="select * from siswa Where nis='$_GET[nis]'"; 
      $qryTampil=mysql_query($sqlTampil); 
      $dataTampil=mysql_fetch_array($qryTampil); 
     ?> 
    <tr bgcolor="#FFFFFF"> 
          <td height="40">Nis </td> 
          <td>: 
          <input name="nis" type="text" id="nis" value="<?php echo $dataTampil['nis']; ?>"></td> 
        </tr> 
        <tr bgcolor="#FFFFFF"> 
          <td height="40">Nama </td> 
          <td>: 
          <input name="nama" type="text" id="nama" value="<?php echo $dataTampil['nama']; ?>"></td> 
        </tr> 
        <tr bgcolor="#FFFFFF"> 
          <td height="40">Kelas</td> 
          <td>: 
          <input name="kelas" type="text" id="kelas" value="<?php echo $dataTampil['kelas']; ?>"></td> 
        </tr> 
        <tr bgcolor="#FFFFFF"> 
          <td height="40">No Absen </td> 
          <td>: 
          <input name="no_absen" type="text" id="no_absen" value="<?php echo $dataTampil['no_absen']; ?>"></td> 
        </tr> 
        <tr bgcolor="#FFFFFF"> 
          <td height="40">Jurusan </td> 
          <td>: 
          <input name="jurusan" type="text" id="jurusan" value="<?php echo $dataTampil['jurusan']; ?>"></td> 
        </tr>   
        <tr bgcolor="#FFFFFF"> 
          <td>&nbsp;</td> 
          <td height="50"><input type="submit" name="Submit" value="Simpan"></td> 
        </tr> 
      </table> 
    </form> 

---------------------------------------------------

Nama File   :  Update_siswa.php

<?php
mysql_connect("localhost","root","root");
mysql_select_db("sisfokol");

     
    $update="UPDATE siswa SET
        nis='$_POST[nis]',
        nama='$_POST[nama]', 
        kelas='$_POST[kelas]', 
        no_absen='$_POST[no_absen]',
        jurusan='$_POST[jurusan]' WHERE nis='$_POST[nis]'"; 
    mysql_query($update); 
     
    echo "<center>Data Berhasil Di Update<center>"; 
    echo "<center><h3><a href=tampil_siswa.php>Back</a></h3></center>"; 
?>



Comments
0 Comments

0 komentar:

Post a Comment