ad

ad

Minggu, 11 Januari 2015

Skrip Input,Output,Edit,Update,Hapus di PhP

Pada kesempatan kali ini saya akan mensharing bagaimana caranya membuat form Input,Output,Edit,Update,Hapus di php dengan mengkoneksikan ke database. Skrip ini berguna untuk mengidentifikasikan data pengguna untuk dapat memasuki sebuah website.Saya selaku aliyud.blogspot.com menerangkan bahwa dalam pembuatan form tsb meliputi database MySQL untuk menyimpan data... Dan untuk mengecek apakah id tsb dapat masuk ke form atau tidak, maka pengidentifikasian tersebut haruslah di cek di data base terlebih dahulu apakah sudah terdaftar atau belum............
OK,langsung saja sobbb.......

Atau filenya langsung bisa didownload disini...
Download untuk file Databasenya          >>> DISINI
Download untuk file Pemrogaman Web >>> DISINI
dalam bentuk rar...

Pertama, buat table database terlebih dahulu pada aplikasi MySQL untuk menyimpan id dan password...disini saya memakai data base XAMPP,  atau
bagi yang belum punya Xampp bisa unduh di link ini Xampp-win32-1.81
Program ini terdiri dari 1 database dan 2 tabel.
Pertama, Buat databasenya dengan nama "uasprak" dan tabel yang pertama dg nama "daftar", di tabel ini terdiri dari 11 kolom yaitu nama,email,dsb . dan setelah itu isikan tabelnya sesuai gambar di bawah ini...

 
lalu simpan database tersebut,,,,,,,
buat tabel yang kedua dengan nama "login" , di tabel ini terdiri dari 3 kolom yaitu id,password,tipe. dan setelah itu isikan tabelnya sesuai gambar di bawah ini...
 
 
utama.php
<html>
<head>
<title>Yes...(^_^)</title>
</head>
<body background="opo.png">
<table width="79%" height="599" border="1" cellpadding="0" cellspacing="0" bordercolor="#ffffff" bgcolor="#003399">
  <tr>
  
    <th width="99%" scope="row">

  <table width="179" height="3%" border="1" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" bgcolor="#99ffff">
  <tr>
    <th width="318" height="23" scope="row">><span class="style6"> MEMBUAT USER BARU</span></th>
  </tr>
</table>
<form name="input_data" action="isidata.php" method="post"><table width="99%" height="599" border="0" cellpadding="0" cellspacing="0" bgcolor="#CCFFFF">
           
   <td><strong>Mendaftar Akun Baru</strong></td>
 <tbody>
        <tr>
            <td>Nama</td>
            <td>:</td>
            <td><input type="char" name="nama" maxlength="33" required="required" /></td>
        </tr>
        <tr>
            <td>Email</td>
            <td>:</td>
            <td><input type="email" name="email" maxlength="17" required="required" /></td>
        </tr>
  <tr>
            <td>Masukkan id baru</td>
            <td>:</td>
            <td><input type="text" name="user" maxlength="19" required="required" /></td>
        </tr>
        <tr>
            <td>Masukkan password baru</td>
            <td>:</td>
            <td><input type="text" name="password" maxlength="19" required="required" /></td>
        </tr>
  <tr>
            <td>Tipe Akun</td>
            <td>:</td><td>
   <select type="text" name="tipe" maxlength="5" required="required">
   <option>Khusus</option><option>Umum</option></select></td>
        </tr>
  <tr>
            <td>Telp</td>
            <td>:</td>
            <td><input type="text" name="telp" maxlength="19" required="required" /></td>
        </tr>
        <tr>
            <td>Tempat Lahir</td>
            <td>:</td>
            <td><input type="text" name="tempat" maxlength="19" required="required" /></td>
        </tr>
  <tr>
            <td>Tanggal Lahir</td><td>:</td>
   <td>Tanggal
   <select type="text" name="tanggal" maxlength="2" required="required">
   <option>1</option><option>2</option><option>3</option>
   <option>4</option><option>5</option><option>6</option>
   <option>7</option><option>8</option><option>9</option>
   <option>10</option><option>11</option><option>12</option>
   <option>13</option><option>12</option><option>13</option>
   <option>16</option><option>17</option><option>18</option>
   <option>19</option><option>20</option><option>21</option>
   <option>22</option><option>23</option><option>24</option>
   <option>25</option><option>26</option><option>27</option>
   <option>28</option><option>29</option><option>28</option>
   <option>31</option></select>
   Bulan
   <select type="text" name="bulan" maxlength="5" required="required">
   <option>Jan</option><option>Feb</option><option>Mar</option>
   <option>Apr</option><option>Mei</option><option>Jun</option>
   <option>Jul</option><option>Agust</option><option>Sep</option>
   <option>Okt</option><option>Nov</option><option>Des</option></select>
   Tahun
   <select type="text" name="tahun" maxlength="5" required="required">
   <option>1990</option><option>1991</option><option>1992</option>
   <option>1993</option><option>1994</option><option>1995</option>
   <option>1996</option><option>1997</option><option>1998</option>
   <option>1999</option><option>2000</option></select></td>
  </tr>
  <tr>
            <td>Alamat</td>
            <td>:</td>
            <td><textarea type="text" name="alamat" maxlength="70" required="required"></textarea></td>
        </tr>
         <tr>
            <td align="left" colspan="3"><input type="submit" name="submit" value="Daftar" /></td>
        </tr>
</tbody>
</table></form>
 </th>
  </tr>
</table>
</body>
</html>

 
tampil.php
 <?PHP
session_start();
?>
<html>
<head>
<title>Yes...(^_^)</title>
</head>
<body background="opo.png">

<table width="79%" height="79" border="1" cellpadding="0" cellspacing="0" bordercolor="#ffffff" bgcolor="#99FFFF">
  <tr>
    <th width="9%" scope="row">

 <table width="1" height="1%" border="0" cellpadding="0" cellspacing="0" bordercolor="#ffffff" bgcolor="#ffffff">
        <tr>
          <th width="3" height="23" scope="row"><?php include('1.php'); ?></span></th>
        </tr></table>

 </th>
    <th width="9%" scope="row" align="center">

 <table width="1" height="1%" border="0" cellpadding="0" cellspacing="0" bordercolor="#ffffff" bgcolor="#ffffff"><tr>
 <?php
$konek = include('koneksi.php');
?>
<?php
$id = $_SESSION['user'];
$query = "select * from daftar where id_baru='$id' ";
$result = mysql_query($query);
//$no = 0;
$buff = mysql_fetch_array($result);
//$no++;
?>
<style type="text/css">
<!--
.style3 {color: #FFFFFF; font-size: 33px; }
.style7 {color: #000000; font-size: 19px; }
-->
</style>
<td><span class="style7"> DATA_PROFIL_ANDA </span> </td>
 <table width="399" height="9%" border="1" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" bgcolor="#99ffff">
  <tr>
    <th width="99" height="23" scope="row"><span class="style7"> Nama<td><?php echo $buff['nama']; ?></td></span></th>
  </tr>
</table>
<table width="399" height="9%" border="1" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" bgcolor="#99ffff">
  <tr>
    <th width="99" height="23" scope="row"><span class="style7"> Email<td><?php echo $buff['email']; ?></td></span></th>
  </tr>
</table>
<table width="399" height="9%" border="1" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" bgcolor="#99ffff">
<tr>
    <th width="99" height="23" scope="row"><span class="style7"> ID<td><?php echo $buff['id_baru']; ?></td></span></th>
  </tr>
</table>
<table width="399" height="9%" border="1" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" bgcolor="#99ffff">
<tr>
    <th width="99" height="23" scope="row"><span class="style7">Password<td><?php echo $buff['password_baru']; ?></td></span></th>
  </tr>
</table>
<table width="399" height="9%" border="1" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" bgcolor="#99ffff">
<tr>
    <th width="99" height="23" scope="row"><span class="style7">Tipe<td><?php echo $buff['tipe']; ?></td></span></th>
  </tr>
</table>
<table width="399" height="9%" border="1" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" bgcolor="#99ffff">
<tr>
    <th width="99" height="23" scope="row"><span class="style7"> Telp<td><?php echo $buff['telp']; ?></td></span></th>
  </tr>
</table>
<table width="399" height="9%" border="1" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" bgcolor="#99ffff">
<tr>
    <th width="99" height="23" scope="row"><span class="style7"> Tempat<td><?php echo $buff['tempat']; ?></td></span></th>
  </tr>
</table>
<table width="399" height="9%" border="1" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" bgcolor="#99ffff">
<tr>
    <th width="99" height="23" scope="row"><span class="style7"> Tanggal Lahir
  <td><?php echo $buff['tanggal']; ?>
  <?php echo $buff['bulan']; ?>
  <?php echo $buff['tahun']; ?></td></span></th>
  </tr>
</table>
<table width="399" height="9%" border="1" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" bgcolor="#99ffff">
<tr>
    <th width="99" height="23" scope="row"><span class="style7"> Status<td><?php echo $buff['alamat']; ?></td></span></th>
  </tr>
</table>
<table width="399" height="9%" border="1" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" bgcolor="#00f0ff">
<tr>
    <th width="199" height="23" scope="row">
  <a href="edit.php?nama=<?php echo $buff['nama']; ?>"><span class="style3">Update Profil</span></a></th>
 <th width="199" height="23" scope="row">
  <a href="hapus.php?nama=<?php echo $buff['nama']; ?>"><span class="style3">Hapus Akun</span></a> </span></th>
  </tr>
</table>
 </th>
  </tr>
</table>
</body>
</html>


edit.php
<?PHP
session_start();
?>
<html>
<head>
<title>Yes...(^_^)</title>
</head>
<body background="opo.png">
<table width="79%" height="79" border="1" cellpadding="0" cellspacing="0" bordercolor="#ffffff" bgcolor="#99FFFF">
  <tr>
    <th width="9%" scope="row">
 <table width="1" height="1%" border="0" cellpadding="0" cellspacing="0" bordercolor="#ffffff" bgcolor="#ffffff">
        <tr>
          <th width="3" height="23" scope="row"><?php include('1.php'); ?></span></th>
        </tr></table>
 </th>
    <th width="99%" scope="row">
 <table width="1" height="1%" border="0" cellpadding="0" cellspacing="0" bordercolor="#ffffff" bgcolor="#ffffff"><tr>
 <?php
$konek = include('koneksi.php');
?>
<?php
$id = $_SESSION['user'];
$query = "select * from daftar where id_baru='$id' ";
$result = mysql_query($query);
//$no = 0;
$buff = mysql_fetch_array($result);
//$no++;
?>
<style type="text/css">
<!--
.style3 {color: #FFFFFF; font-size: 33px; }
.style7 {color: #000000; font-size: 19px; }
-->
</style>
<td><span class="style7"> DATA_PROFIL_ANDA </span> </td>
<form name="form1" method="post" action="update.php""0"bgcolor="#ffffff">
<table>
<tr>
        <tr>
            <td>Nama</td>
            <td>:</td>
            <td><input type="char" name="nama" maxlength="33" value="<?php echo $buff['nama']; ?>" /></td>
        </tr>
        <tr>
            <td>Email</td>
            <td>:</td>
            <td><input type="email" name="email" maxlength="17" value="<?php echo $buff['email']; ?>" /></td>
        </tr>
  <tr>
            <td>Masukkan id baru</td>
            <td>:</td>
            <td><input type="text" name="user" maxlength="19" value="<?php echo $buff['id_baru']; ?>" /></td>
        </tr>
        <tr>
            <td>Masukkan password baru</td>
            <td>:</td>
            <td><input type="text" name="password" maxlength="19" value="<?php echo $buff['password_baru']; ?>" /></td>
        </tr>
  <tr>
            <td>Tipe Akun</td>
            <td>:</td><td>
   <select type="text" name="tipe" maxlength="5" value="<?php echo $buff['tipe']; ?>">
   <option>Khusus</option><option>Umum</option></select></td>
        </tr>
  <tr>
            <td>Telp</td>
            <td>:</td>
            <td><input type="text" name="telp" maxlength="19" value="<?php echo $buff['telp']; ?>" /></td>
        </tr>
        <tr>
            <td>Tempat Lahir</td>
            <td>:</td>
            <td><input type="text" name="tempat" maxlength="19" value="<?php echo $buff['tempat']; ?>" /></td>
        </tr>
  <tr>
            <td>Tanggal Lahir</td><td>:</td>
   <td>Tanggal
   <select type="text" name="tanggal" maxlength="2" value="<?php echo $buff['tanggal']; ?>">
   <option>1</option><option>2</option><option>3</option>
   <option>4</option><option>5</option><option>6</option>
   <option>7</option><option>8</option><option>9</option>
   <option>10</option><option>11</option><option>12</option>
   <option>13</option><option>12</option><option>13</option>
   <option>16</option><option>17</option><option>18</option>
   <option>19</option><option>20</option><option>21</option>
   <option>22</option><option>23</option><option>24</option>
   <option>25</option><option>26</option><option>27</option>
   <option>28</option><option>29</option><option>28</option>
   <option>31</option></select>
   Bulan
   <select type="text" name="bulan" maxlength="5" value="<?php echo $buff['bulan']; ?>">
   <option>Jan</option><option>Feb</option><option>Mar</option>
   <option>Apr</option><option>Mei</option><option>Jun</option>
   <option>Jul</option><option>Agust</option><option>Sep</option>
   <option>Okt</option><option>Nov</option><option>Des</option></select>
   Tahun
   <select type="text" name="tahun" maxlength="5" value="<?php echo $buff['tahun']; ?>">
   <option>1990</option><option>1991</option><option>1992</option>
   <option>1993</option><option>1994</option><option>1995</option>
   <option>1996</option><option>1997</option><option>1998</option>
   <option>1999</option><option>2000</option></select></td>
  </tr>
  <tr>
            <td>Status</td>
            <td>:</td>
            <td><textarea type="text" name="alamat" maxlength="70" value="<?php echo $buff['alamat']; ?>"></textarea></td>
        </tr>
  <tr>
  <td><input value="Simpan" type="submit" name="submit"/>
  <input type="button" value="Kembali" onClick="self.history.back()"></td></tr>
</table>
</form>
 </th>
  </tr>
</table>
</body>
</html>
 
1.php
 
hapus.php
 
 
 home.php
 
isidata.php
 
 isilogin.php
 
koneksi.php
 
 
update.php
 
logout.php
 

0 komentar: