Untitled
raw download clone
PHP
views 56
,
size 11013 b
//Tambah siswa
<!DOCTYPE html>
<html lang="en">

<head>

  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <meta name="description" content="">
  <meta name="author" content="">

  <!-- Custom fonts for this template -->
  <link href="vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
  <link href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i" rel="stylesheet">

  <!-- Custom styles for this template -->
  <link href="css/sb-admin-2.min.css" rel="stylesheet">

  <!-- Custom styles for this page -->
  <link href="vendor/datatables/dataTables.bootstrap4.min.css" rel="stylesheet">

</head>

<body id="page-top">

  <!-- Page Wrapper -->
  <div id="wrapper">

        <!-- Begin Page Content -->
        <div class="container-fluid">
        <br /<br />         
       <h1 class="h3 mb-2 text-gray-800">Tambah Data Siswa</h1>
       <br><br>
          <!-- DataTales Example -->
          <div class="card shadow mb-4">
            <div class="card-header py-3">
              
            </div>
            <div class="card-body">
              <div class="table-responsive">              
                <h1 align=center>Tambah Data Siswa </h1>
      <form action = 'proses_tambah_siswa.php' method = 'POST'>
      <table align=center cellspacing=1>
                 <tr><td>NISN</td><td><input class="form-control" type=number min=1000000000 max=9999999999 size=25 name=nisn></td></tr>
                 <tr><td>NIS</td><td><input class="form-control" type=number min=10000000 max=99999999 size=25 name=nis></td></tr>
                 <tr><td>Nama Lengkap</td><td><input class="form-control" type=text size=25 name=nama></td></tr>
                 <tr><td>Kelas</td><td><select class="custom-select" name="id_kelas">
                 <option value="">--Pilih Kelas--</option>
                 <?php 
                 include "koneksi.php";
 
                 $tampil = "SELECT * FROM kelas";            
                 $hasil = mysqli_query($koneksi, $tampil);              
                 while ($r=mysqli_fetch_array($hasil)){            
                   echo "<option value='$r[id_kelas]'>$r[nama_kelas] ($r[kompetensi_keahlian])</option>";
                 }
                 ?>
                 </select></td></tr>
                 <tr><td>Alamat</td><td><input class="form-control" type=text size=25 name=alamat></td></tr>
                 <tr><td>No Telephone</td><td><input class="form-control" type=number size=25 name=no_telp></td></tr>
                 <tr><td>Id SPP (Tahun, Nominal)</td><td><select class="custom-select" name="id_spp">
                 <option value="">--Pilih Id SPP--</option>
                 <?php 
                 include "koneksi.php";
 
                 $tampil = "SELECT * FROM spp";            
                 $hasil = mysqli_query($koneksi, $tampil);              
                 while ($r=mysqli_fetch_array($hasil)){            
                   echo "<option value='$r[id_spp]'>$r[id_spp] ($r[tahun], $r[nominal])</option>";
                 }
                 ?>
                 </select></td></tr>
                 <tr><td colspan=2 align=center><input class="btn btn-outline-success" type=submit value=Tambah></td></tr>
      </table>
        
              </div>
            </div>
          </div>

        </div>
        <!-- /.container-fluid -->
      </div>
      <!-- End of Main Content -->

    </div>
    <!-- End of Content Wrapper -->

  </div>
  <!-- End of Page Wrapper -->

  <!-- Scroll to Top Button-->
  <a class="scroll-to-top rounded" href="#page-top">
    <i class="fas fa-angle-up"></i>
  </a>

  <!-- Logout Modal-->
  <div class="modal fade" id="logoutModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <div class="modal-dialog" role="document">
      <div class="modal-content">
        <div class="modal-header">
          <h5 class="modal-title" id="exampleModalLabel">Ready to Leave?</h5>
          <button class="close" type="button" data-dismiss="modal" aria-label="Close">
            <span aria-hidden="true">�</span>
          </button>
        </div>
        <div class="modal-body">Select "Logout" below if you are ready to end your current session.</div>
        <div class="modal-footer">
          <button class="btn btn-secondary" type="button" data-dismiss="modal">Cancel</button>
          <a class="btn btn-primary" href="login.html">Logout</a>
        </div>
      </div>
    </div>
  </div>
</body>
</html>
//Proses tambah
<?php 
include "koneksi.php";

$nisn = $_POST['nisn'];
$nis = $_POST['nis'];
$nama = $_POST['nama'];
$id_kelas = $_POST['id_kelas'];
$alamat = $_POST['alamat'];
$no_telp = $_POST['no_telp'];
$id_spp = $_POST['id_spp'];

     
$masuk = "INSERT INTO siswa (nisn, nis, nama, id_kelas, alamat, no_telp, id_spp)
                 VALUES ('$nisn',
                     '$nis',
                     '$nama', 
                     '$id_kelas',
                     '$alamat',
                     '$no_telp',
                     '$id_spp')";

mysqli_query($koneksi, $masuk);

header("location:media.php?module=tampil_siswa");
?>

//Edit siswa
<!DOCTYPE html>
<html lang="en">

<head>

  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <meta name="description" content="">
  <meta name="author" content="">

  <!-- Custom fonts for this template -->
  <link href="vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
  <link href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i" rel="stylesheet">

  <!-- Custom styles for this template -->
  <link href="css/sb-admin-2.min.css" rel="stylesheet">

  <!-- Custom styles for this page -->
  <link href="vendor/datatables/dataTables.bootstrap4.min.css" rel="stylesheet">

</head>

<body id="page-top">

  <!-- Page Wrapper -->
  <div id="wrapper">

        <!-- Begin Page Content -->
        <div class="container-fluid">
        <br /<br />         
       <h1 class="h3 mb-2 text-gray-800">Ubah Data Siswa</h1>
       <br><br>
<div class="card shadow mb-4">
            <div class="card-header py-3">
              
            </div>
            <div class="card-body">
              <div class="table-responsive">
<?php
include "koneksi.php";
$nisn = $_GET['nisn'];

 $tampil = "SELECT * FROM siswa where nisn=$nisn";            
 $hasil = mysqli_query($koneksi, $tampil); 
 $r=mysqli_fetch_array($hasil);
 
echo "<h1 align=center>Ubah Data Siswa </h1>
      <form action = 'proses_edit_siswa.php' method = 'POST'>
      <table align=center cellspacing=1>
                 <br>
                 <input type=hidden name=nisn value = $r[nisn]>
                 <tr><td>NIS</td><td><input class='form-control' type=text size=25 name=nis value = '$r[nis]'></td></tr>
                 <tr><td>Nama Lengkap</td><td><input class='form-control' type=text size=25 name=nama value='$r[nama]'></td></tr>
                 <tr><td>Kelas</td><td><select class='custom-select' name='id_kelas'>
                 <option value=''>--Pilih Kelas--</option>"; ?>
                  <?php
                 include 'koneksi.php';
 
                 $tampil2 = 'SELECT * FROM kelas';            
                 $hasil2 = mysqli_query($koneksi, $tampil2);              
                 while ($row=mysqli_fetch_array($hasil2)){            
                   echo "<option value='$row[id_kelas]'>$row[nama_kelas] ($row[kompetensi_keahlian])</option>";
                 }
                 ?>
                 <?php
echo             "</select></td></tr>
                 <tr><td>Alamat</td><td><input class='form-control' type=text size=25 name=alamat  value='$r[alamat]'></td></tr>
                 <tr><td>No Telephone</td><td><input class='form-control' type=text size=25 name=no_telp value='$r[no_telp]'></td></tr>
                 <tr><td>Id SPP (Tahun, Nominal)</td><td><select class='custom-select' name='id_spp'>
                 <option value=''>--Pilih Id SPP--</option>"; ?>
                  <?php
                 include 'koneksi.php';
 
                 $tampil2 = 'SELECT * FROM spp';            
                 $hasil2 = mysqli_query($koneksi, $tampil2);              
                 while ($row=mysqli_fetch_array($hasil2)){            
                   echo "<option value='$row[id_spp]'>$row[id_spp] ($row[tahun], $row[nominal])</option>";
                 }
                 ?>
                 <?php
echo             "</select></td></tr>
                 <tr><td colspan=2 align=center><input class='btn btn-outline-success' type=submit value=Ubah></td></tr>
      </table>";  
 ?>
</div></div></div>
 <!-- /.container-fluid -->
 </div>
      <!-- End of Main Content -->

    </div>
    <!-- End of Content Wrapper -->

  </div>
  <!-- End of Page Wrapper -->

  <!-- Scroll to Top Button-->
  <a class="scroll-to-top rounded" href="#page-top">
    <i class="fas fa-angle-up"></i>
  </a>

  <!-- Logout Modal-->
  <div class="modal fade" id="logoutModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <div class="modal-dialog" role="document">
      <div class="modal-content">
        <div class="modal-header">
          <h5 class="modal-title" id="exampleModalLabel">Ready to Leave?</h5>
          <button class="close" type="button" data-dismiss="modal" aria-label="Close">
            <span aria-hidden="true">�</span>
          </button>
        </div>
        <div class="modal-body">Select "Logout" below if you are ready to end your current session.</div>
        <div class="modal-footer">
          <button class="btn btn-secondary" type="button" data-dismiss="modal">Cancel</button>
          <a class="btn btn-primary" href="login.html">Logout</a>
        </div>
      </div>
    </div>
  </div>
</body>
</html>

// proses edit
<?php
include "koneksi.php";

$nisn = $_POST['nisn'];
$nis = $_POST['nis'];
$nama = $_POST['nama'];
$id_kelas = $_POST['id_kelas'];
$alamat = $_POST['alamat'];
$no_telp = $_POST['no_telp'];
$id_spp = $_POST['id_spp']; 


$ubah  = "UPDATE siswa
          SET nis = '$nis',
              nama = '$nama',
              id_kelas = '$id_kelas',
              alamat = '$alamat',
              no_telp = '$no_telp',
              id_spp = '$id_spp'  
              WHERE nisn ='$nisn'";
               
    mysqli_query($koneksi, $ubah);
header('location:media.php?module=tampil_siswa');   

?>
close fullscreen
Login or Register to edit or fork this paste. It's free.