Jumat, 15 April 2016

membuat form pendaftaran




index.php

 <html>
    <head><title>Form Pendaftaran</title></head>
    <body>
    <form action="proses.php" method="POST">
    <table border="4" bgcolor="A9C5EB" align="center" height="500" width="400" cellpadding="20">
    <tr>
    <td>
      <h1>FROM PENDAFTARAN</h1>
      <p>SMK PGRI 1 MEJOBO </p>
        <input type="text" Name="nama" size="46" placeholder="Nama">
        <input type="text" Name="email" size="46" placeholder="Email Anda"><br><br>
        <input type="password" Name="sandi" size="46" placeholder="Kata Sandi"><br>
    <p><b> Tanggal Lahir </b></p>
    <p>
      <select name="Tanggal">
        <option>-Tanggal-</option>
        <option value="1">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">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>
        <option value="32">32</option>
      </select>
      <select name="Bulan">
        <option>-Bulan-</option>
        <option value="1">Januari</option>
        <option value="2">Februari</option>
        <option value="3">Maret</option>
        <option value="4">April</option>
        <option value="5">Mei</option>
        <option value="6">Juni</option>
        <option value="7">Juli</option>
        <option value="8">Agustus</option>
        <option value="9">September</option>
        <option value="10">Oktober</option>
        <option value="11">November</option>
        <option value="12">Desember</option>
      </select>
      <select name="Tahun">
        <option>-Tahun-</option>
        <option value="1980">1980</option>
        <option value="1981">1981</option>
        <option value="1982">1982</option>
        <option value="1983">1983</option>
        <option value="1984">1984</option>
        <option value="1985">1985</option>
        <option value="1986">1986</option>
        <option value="1987">1987</option>
        <option value="1988">1988</option>
        <option value="1989">1989</option>
        <option value="1990">1990</option>
        <option value="1991">1991</option>
        <option value="1992">1992</option>
        <option value="1993">1993</option>
        <option value="1994">1994</option>
        <option value="1995">1995</option>
        <option value="1996">1996</option>
        <option value="1997">1997</option>
        <option value="1998">1998</option>
        <option value="1999">1999</option>
        <option value="2000">2000</option>
        <option value="2001">2001</option>
        <option value="2002">2002</option>
        <option value="2003">2003</option>
        <option value="2004">2004</option>
        <option value="2005">2005</option>
        <option value="2006">2006</option>
        <option value="2007">2007</option>
        <option value="2008">2008</option>
        <option value="2009">2009</option>
        <option value="2010">2010</option>
        <option value="2011">2011</option>
        <option value="2012">2012</option>
        <option value="2013">2013</option>
        <option value="2014">2014</option>
        <option value="2015">2015</option>
      </select>
      <br>
      <br>
      <input type="radio" name="Kelamin" value="L">
      Laki Laki
      <input type="radio" name="Kelamin" value="P">
      Perempuan      </p>
    <p><label></label>
    </p>
      <textarea name="comentar" id="textarea" placeholder=":::::knapa ingin sekolah disini::::::"></textarea>
    <p><br>
      <br>
      <input value="Kirim" style="background-color: 4985D0; height: 50; width: 150;"type="submit">
      </p></td>
    </tr>
   <a href="tampil.php">tampil</a>
    </body>
    </table>
    </form>
    </body>
    </html>  





proses.php

 <?php

include ('koneksi.php');
   
      $nama   = $_POST['nama'];
      $email    = $_POST['email'];
      $sandi        = $_POST['sandi'];
      $tgl_lhr             = $_POST['tgl_lhr'];
      $kelamin    = $_POST['kelamin'];
      $comentar    = $_POST['comentar'];
    

  $query="INSERT INTO daftar set nama='$nama', email='$email', sandi='$sandi', tgl_lhr='$tgl_lhr', kelamin='$kelamin', comentar='$comentar'";

     $simpan= mysqli_query($db, $query);
      if ($simpan)
         {
          echo "<script>alert('Data berhasil di tambah')</script>";
          echo "<meta http-equiv=Refresh content=0;url=tampil.php>";
          }
          else
          {
          echo "<script>alert('Maaf, data gagal di tambah')</script>";
          }
 




tampil.php

<?php
    include 'koneksi.php';

    // di sinii kita akan menampilkan data dari pembeli yang sudah melakaukan registrasi.//

$query = mysqli_query ($db, "SELECT * FROM daftar");
?>

<html>
    <head>
        <title> form daftar</title>
        <style type="text/css">
        .td {
            text-align: center;
        }
        .th {
            text-align: center;
            padding: 10px;
        }
        </style>
    </head>
    <body>
        <table align="center" border="2">
            <tr>
                <ins>
                <th class="th"><ins> NAMA </ins></th>
                <th class="th"> <ins> EMAIL</ins></th>
                <th class="th"> <ins>PASSWORD</ins></th>
                <th class="th"> <ins>TANGAL LAHIR</th>
                <th class="th"><ins> KELAMIN </ins></th>
                <th class="th"><ins> COMEN </ins></th>
       
                </ins>
            </tr>       
            <tr>
      <?php while ($daftar = mysqli_fetch_array($query)){ ?>
       
        <td class="td"> <?php echo $daftar['nama'] ?></td>
        <td class="td"> <?php echo $daftar['email'] ?></td>
        <td class="td"> <?php echo $daftar['sandi'] ?></td>
        <td class="td"> <?php echo $daftar['tgl_lhr'] ?></td>
        <td class="td"> <?php echo $daftar['kelamin'] ?></td>
        <td class="td"> <?php echo $daftar['comentar'] ?></td>
        <td>
             <a href="edit-pembelian.php?id_pendaftaran=<?php echo $pendaftaran['id_pendaftaran']; ?>">
                        <button>Edit</button>
           </a>
           <a href="hapus-pendaftaran.php?id_pendaftaran=<?php echo $pendaftaran['id_pendaftaran']; ?>" onclick="return confirm('Hapus data ini?');">
                        <button>Delete</button>
           </a>
       </td>
            </tr>
    <?php }
   ?>
        </table>
     </body>
</html>


koneksi.php

<?php
$host ="localhost";
$user ="root";
$pass ="risaku";
$db   ="form";

        $db =mysqli_connect($host,$user,$pass,$db) or die("gagal koneksi ke database");

?>
   

0 komentar:

Posting Komentar