Menampilkan Data Inputan dengan PHP tanpa database




file tampil.php
<!DOCTYPE html>
<html>
<head>
 <meta charset="utf-8">
 <meta http-equiv="X-UA-Compatible" content="IE=edge">
 <title>Tugas 2</title>
 <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,600' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="css/normalize.css" media="screen">
<link rel="stylesheet" href="css/grid.css" media="screen">
<link rel="stylesheet" href="css/style.css" media="screen">
<link rel="stylesheet" href="plugin/font-awesome/css/font-awesome.css" media="screen">
</head>
<body background="images/10.jpg">

<div class="content">
 <div class="container">
  <div class="panel panel-primary">
   <div class="panel-heading">
    <h3 class="panel-title"><center>Inputan</center></h3>
   </div>
   <div class="panel-body">
    <?php
     session_start();
      if((empty($_GET["destroy"])==FALSE)){
        session_destroy();
        echo "<a href='beli_n.php'>kembali</a>";
       }
    ?>

 <form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
 <pre>
  Nama   :<input type="text" name="nama"><br>
  NIM    :<input type="text" name="nim"><br>
  Alamat :<input type="text" name="alamat"><br>
  <input type="submit" name="bhasil" value="Masukkan"> <input type="reset" name="bbatal" value="Batal">
 </pre>

 <table width="100%" border="1">
 <tr>
  <td><center>No</center></td>
  <td><center>Nama</center></td>
  <td><center>Nim</center></td>
  <td><center>Alamat</center></td>
 </tr>
 <?php
 $awal=1;
 if (@$_POST["nama"]!=''){
  if (empty($_SESSION["isi"])==TRUE){
   $_SESSION["isi"]=1;
  }else{
   $_SESSION["isi"]++;
  }

  @$nama=trim($_POST["nama"]);
  @$nim=trim($_POST["nim"]);
  @$alamat=trim($_POST["alamat"]);
  $_SESSION["akhir"][$_SESSION["isi"]]=array($nama,$nim,$alamat);
 }
  @$awal = $_SESSION["isi"];

  for ($i=0;$i<=$awal;$i++) {
  if (@$_SESSION['akhir'][$i][0]!=''){
   echo "<tr>
     <td align=center>$i</td>
     <td align=center>".@$_SESSION['akhir'][$i][0]."</td>
     <td align=center>".@$_SESSION['akhir'][$i][1]."</td>
     <td align=center>".@$_SESSION['akhir'][$i][2]."</td>
     ";
   }
 
  }


  echo "<a href='aksi.php'><input type='button' value='Reset'></a>";
 ?>
 </table>
   </div>
  </div>
 </div>
</div>

<script src="js/bootstrap.js" type="text/javascript" charset="utf-8" async defer></script>
<script src="js/bootstrap.min.js" type="text/javascript" charset="utf-8" async defer></script>
</body>
</html>



file aksi.php
<?php
session_start();
session_destroy();
?>
<meta http-equiv='refresh' content='0;url=http://localhost/PWD/tampil.php'>

Download filenya disini

Related Posts:

0 Response to "Menampilkan Data Inputan dengan PHP tanpa database"

Post a Comment