form - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of form.php

  1. <body class="main-layout">
  2.         <?php
  3.              include 'database.php';
  4.      
  5.              session_start();
  6.              if (!isset($_SESSION['login'])) {
  7.                header("location:login.php");
  8.              }
  9.              if ($_SESSION['level'] != 1 || $_SESSION['level'] != 2){
  10.                if ($_SESSION['level'] == 3){
  11.                    header("location:home_sekolah.php");
  12.                } elseif ($_SESSION['level'] == 1 || $_SESSION['level'] == 2) {
  13.                    true;
  14.                }                    
  15.                else{
  16.                    header("location:login.php");
  17.                }
  18.            }
  19.         ?>
  20.         <?php
  21.          use system\crud as crud;
  22.          $sesi = $_SESSION['id'];
  23.          error_reporting(0);
  24.  
  25.          $db = new crud();
  26.  
  27.          $temu_nisn = $db->tampil_edit('siswa','nisn',$_POST['nisn']);
  28.         //proses checker------------------------------------------------
  29.         if( empty($_POST['no_seri']) ||  empty($_POST['nisn'])  || empty($_POST['tgl_terbit'])){
  30.             echo "<script>
  31.                 alert('Mohon mengisi seluruh data dengan benar!');
  32.                 history.back(self);
  33.             </script>";
  34.             die;
  35.         } elseif ($temu_nisn['nisn'] != $_POST['nisn']){ 
  36.             echo "<script>
  37.             alert('NISN yang diinputkan tidak terdaftar');
  38.             history.back(self);
  39.             </script>";
  40.             die;
  41.         }
  42.         else { //star kembar
  43.             //cek data kembar
  44.             $cek1 = $db->data_kembar_string('ijazah','no_seri',$_POST['no_seri']);           
  45.             $cek3 = $db->data_kembar_string('ijazah','nisn',$_POST['nisn']);
  46.             
  47.  
  48.             if ($cek1 > 0 || $cek3 > 0) {
  49.                 if($cek1 > 0){
  50.                 echo "<script>
  51.                     alert('NO. SERI telah terdaftar! Mohon isi kembali data Anda dengan baik.');
  52.                     history.back(self);
  53.                     </script>";
  54.                     die;
  55.                 }
  56.                 //-------------------------------------Error-----------------------------------
  57.                 if ($cek3 > 0) {
  58.                     //mengecek apakah nisn yg diinput berada di jenjang pendidikan yang sama
  59.                     $jenjang = $db->cek_jenjang('kd_jenjang','nisn','ijazah','nisn',$_POST['nisn'],'no_ijazah');
  60.                     //cek apakah di jenjang yang sama
  61.                     foreach($jenjang as $x):
  62.                         if($x['kd_jenjang'] == $_POST['kd_jenjang']){
  63.                         echo $x['kd_jenjang'];
  64.                         echo $_POST['kd_jenjang'];
  65.                         die;
  66.                     }
  67.                     endforeach;
  68.                 }
  69.                 //----------------------------------------------------------------------------------
  70.             }          
  71.         }
  72.         //end proses checker--------------------------------------------
  73.         //id = no_ijazah
  74.         if (isset($_POST['no_sekolah'])){
  75.             $no_sekolah = $_POST['no_sekolah'];
  76.             $sekolah = $db->tampil_edit('sekolah','no_sekolah',$no_sekolah);
  77.             $siswa = $db->tampil_edit('siswa','nisn',$_POST['nisn']);
  78.         } else {
  79.             if (isset($_SESSION['refresh'])){
  80.                 $no_sekolah = $_SESSION['no_sekolah'];
  81.                 $nisn = $_SESSION['nisn'];
  82.                 $sekolah = $db->tampil_edit('sekolah','no_sekolah',$no_sekolah);
  83.                 $siswa = $db->tampil_edit('siswa','nisn',$nisn);
  84.             }   
  85.         }
  86.  
  87.   ?>
  88.         <!-- header -->
  89.         <header class="section">
  90.             <!-- header inner -->
  91.             <div
  92.                 class="header"
  93.                 style="position: fixed; background-color: #136af8; height: 100px; padding-top: 30px;">
  94.                 <div class="container">
  95.                     <div class="row">
  96.                         <div class="col-xl-3 col-lg-3 col-md-3 col-sm-3 col logo_section">
  97.                             <div class="full" style="margin-bottom: 0px;">
  98.                                 <div class="center-desk">
  99.                                     <div class="logo logo-img-kemendikbud">
  100.                                         <a href="https://www.kemdikbud.go.id/" target="_blank"><img src="logo/kemendikbud-bg.png" alt="#"></a>
  101.                                     </div>
  102.                                     <div class="logo logo-img-jateng">
  103.                                         <a href="http://www.pdkjateng.go.id/" target="_blank"><img src="logo/jawa_tengah.png" alt="#"></a>
  104.                                     </div>
  105.                                     <div class="logo logo-img-kab">
  106.                                         <a href="https://www.karanganyarkab.go.id/" target="_blank"><img src="logo/kabupaten_karanganyar.png" alt="#"></a>
  107.                                     </div>
  108.                                 </div>
  109.                             </div>
  110.                         </div>
  111.                         <div class="col-xl-9 col-lg-9 col-md-9 col-sm-9">
  112.                             <div class="menu-area">
  113.                                 <div class="limit-box">
  114.                                 <nav class="nav navbar navbar-expand-lg navbar-light" style="background-color: #136AF8;">
  115.                                     <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
  116.                                         <span class="navbar-toggler-icon" style="color: whitesmoke;"></span>
  117.                                     </button>
  118.                                 <div class="collapse navbar-collapse" id="navbarNavAltMarkup">
  119.                                     <div class="navbar-nav">
  120.                                         <a class="nav-item nav-link active" href="home_backend.php" style="color:white; font-size:16px; font-weight:500; line-height:20px;text-align:center; padding: 5px 20px 22px 20px; font-family: 'Poppins', sans-serif; line-height:23.32px; text-transform:uppercase;">Home</a>
  121.                                         <a class="nav-item nav-link" href="form_user_backend.php?id=<?= $id; ?>&action=update" style="color:white; font-size:16px; font-weight:500; line-height:20px;text-align:center; padding: 5px 20px 22px 20px; font-family: 'Poppins', sans-serif; line-height:23.32px;text-transform:uppercase;">Update Bio</a>
  122.                                         <a class="nav-item nav-link" href="jenjang.php?action=ijazah" style="color:white; font-size:16px; font-weight:500; line-height:20px;text-align:center; padding: 5px 20px 22px 20px; font-family: 'Poppins', sans-serif; line-height:23.32px;text-transform:uppercase;">Data Ijazah</a>
  123.                                         <a class="nav-item nav-link" href="jenjang.php?action=sekolah" style="color:white; font-size:16px; font-weight:500; line-height:20px;text-align:center; padding: 5px 20px 22px 20px; font-family: 'Poppins', sans-serif; line-height:23.32px;text-transform:uppercase;">Data Sekolah</a>
  124.                                         <?php if($_SESSION['level'] == 1): ?>
  125.                                         <a class="nav-item nav-link" href="tampil_data_admin.php" style="color:white; font-size:16px; font-weight:500; line-height:20px;text-align:center; padding: 5px 20px 22px 20px; font-family: 'Poppins', sans-serif; line-height:23.32px;text-transform:uppercase;">Data Admin</a>
  126.                                         <?php endif; ?>
  127.                                         <a class="nav-item nav-link" href="logout.php" style="color:white; font-size:16px; font-weight:500; line-height:20px;text-align:center; padding: 5px 20px 22px 20px; font-family: 'Poppins', sans-serif; line-height:23.32px;text-transform:uppercase;" onclick="return confirm('Anda ingin LOGOUT dari Sistem?')">Logout</a>
  128.                                     </div>
  129.                                 </div>
  130.                                 </nav>
  131.                                 </div>
  132.                             </div>
  133.                         </div>
  134.                     </div>
  135.                 </div>
  136.             </div>
  137.             <!-- end header inner -->
  138.         </header>
  139.         <!-- end header -->
  140.         <div
  141.             class="contact_us_2 layout_padding paddind_bottom_0"
  142.             style="margin-top: 47px;">
  143.             <div class="container" style="background-color: #136AF8; padding-bottom: 60px;">
  144.                 <div class="row">
  145.                     <div class="col-md-12">
  146.                         <div class="email_btn">
  147.                             <!--form-->
  148.                             <form autocomplete="off" 
  149.                                 method="POST"
  150.                                 enctype="multipart/form-data"
  151.                                 action="
  152.                                 <?php  
  153.                                     if(isset($no_ijazah)){
  154.                                         echo "proses_ijazah.php?action=add";
  155.                                     }
  156.                                 ?>"
  157.                             >
  158.                                 <h1
  159.                                     style="color: white; letter-spacing:5px; font-weight:bold; text-align:center; margin: 0 0 30px 0; font-size: 30px">
  160.                                     <?php
  161.                                         echo "Tambah Ijazah";
  162.                                     ?>
  163.                                     
  164.                                 </h1>
  165.  
  166.                                 <!--isi form-->
  167.                                 <?php if(isset($_GET['id'])): ?>
  168.                                     <input type="hidden" value="<?= $no_sekolah; ?>" name="no_sekolah">
  169.                                     <input type="hidden" value="<?= $sekolah['kd_jenjang']; ?>" name="kd_jenjang">
  170.                                 <?php endif; ?>
  171.                                 <?php if(isset($_SESSION['refresh'])): ?>
  172.                                     <input type="hidden" value="<?= $_SESSION['no_sekolah']; ?>" name="no_sekolah">
  173.                                     <input type="hidden" value="<?= $sekolah['kd_jenjang']; ?>" name="kd_jenjang">
  174.                                 <?php endif; ?>
  175.                                 <!--untuk update-->
  176.                                 <?php if(isset($_GET['no'])): ?>
  177.                                 <input type="hidden" value="<?= $ijazah['no_seri'] ?>" name="seriLama">
  178.                                 <input type="hidden" value="<?= $ijazah['nisn'] ?>" name="nisnLama">
  179.                                 <input type="hidden" value="<?= $ijazah['no_peserta_un'] ?>" name="unLama">
  180.                                 <input type="hidden" value="<?= $no_ijazah ?>" name="no_ijazah">
  181.                                 <input type="hidden" value="<?= $ijazah['lembar_ijazah'] ?>" name="fileLama">
  182.                                 <input type="hidden" value="<?= $no_ijazah ?>" name="no_ijazah">
  183.                                 <input type="hidden" value="<?= $ijazah['no_sekolah'] ?>" name="no_sekolah">
  184.                                 <?php endif; ?>
  185.  
  186.                                 <div class="row">
  187.                                     <div class="col-md-6" style="padding: 0 20px 0 20px;">
  188.                                         <!--No Seri-->
  189.                                         <div class="form-group">
  190.                                             <label
  191.                                                 style="color: white; font-weight:bolder; letter-spacing:2px; margin-top:0px;"
  192.                                                 id="no_seri">No. Seri Ijazah :</label>
  193.                                             <input
  194.                                                 style="padding-left: 15px;"
  195.                                                 type="text"
  196.                                                 class="form-control form-control-sm"
  197.                                                 name="no_seri"
  198.                                                 readonly
  199.                                                 value="<?php 
  200.                                                     if ($_SESSION['no_seri'] != null){
  201.                                                         echo $_SESSION['no_seri'];
  202.                                                     } else {
  203.                                                         echo $_POST['no_seri'] ;
  204.                                                     }
  205.                                                  ?>"
  206.                                                 >
  207.                                         </div>
  208.                                         <!--nisn-->
  209.                                         <div class="form-group">
  210.                                             <label
  211.                                                 style="color: white; font-weight:bolder; letter-spacing:2px; margin-top:10px;"
  212.                                                 id="nisn">NISN :</label>
  213.                                             <div class="form-group">
  214.                                                 <input
  215.                                                     type="text"
  216.                                                     style="padding-left: 15px;"
  217.                                                     class="form-control form-control-sm"
  218.                                                     readonly
  219.                                                     name="nisn"
  220.                                                     value="<?php 
  221.                                                     if ($_SESSION['nisn'] != null){
  222.                                                         echo $_SESSION['nisn'];
  223.                                                     } else {
  224.                                                         echo $_POST['nisn'] ;
  225.                                                     }
  226.                                                  ?>">
  227.                                             </div>
  228.                                         </div>
  229.                                         <!--nama siswa-->
  230.                                         <div class="form-group">
  231.                                             <label
  232.                                                 style="color: white; font-weight:bolder; letter-spacing:2px; margin-top:10px;"
  233.                                                 id="nama_siswa">Nama Siswa :</label>
  234.                                             <div class="form-group">
  235.                                                 <input
  236.                                                     type="text"
  237.                                                     style="padding-left: 15px;"
  238.                                                     class="form-control form-control-sm"
  239.                                                     readonly
  240.                                                     name="nama_siswa"
  241.                                                     value="<?= $siswa['nama_siswa'] ?>">
  242.                                             </div>
  243.                                         </div>
  244.                                         <!--nama siswa-->
  245.                                         <div class="form-group">
  246.                                             <label
  247.                                                 style="color: white; font-weight:bolder; letter-spacing:2px; margin-top:10px;"
  248.                                                 id="tgl_lahir">Tgl. Lahir :</label>
  249.                                             <div class="form-group">
  250.                                                 <input
  251.                                                     type="text"
  252.                                                     style="padding-left: 15px; width:150px; margin:0 auto 0 11px;"
  253.                                                     class="form-control form-control-sm"
  254.                                                     readonly
  255.                                                     name="tgl_lahir"
  256.                                                     value="<?= $siswa['tgl_lahir'] ?>">
  257.                                             </div>
  258.                                         </div>
  259.                                     </div>
  260.  
  261.                                     <div class="col-md-6" style="padding: 0 20px 0 20px;"> 
  262.                                         <!--nama sekolah-->
  263.                                         <div class="form-group">
  264.                                             <label
  265.                                                 style="color: white; font-weight:bolder; letter-spacing: 2px;"
  266.                                                 id="sekolah">Sekolah :</label>
  267.                                                 <input
  268.                                                     type="text"
  269.                                                     style="padding-left: 15px;"
  270.                                                     class="form-control form-control-sm"
  271.                                                     readonly
  272.                                                     name="tgl_lahir"
  273.                                                     value="<?= $sekolah['nama_sekolah'] ?>">
  274.                                         </div>
  275.                                         <!--tgl terbit-->
  276.                                         <div class="form-group">
  277.                                             <label
  278.                                                 style="color: white; font-weight:bolder; letter-spacing: 2px;"
  279.                                                 id="tgl_terbit">Tgl. Terbit Ijazah :</label>
  280.                                             <input
  281.                                                 type="date"
  282.                                                 style="padding-left: 15px; width:150px; margin:0 auto 0 11px;"
  283.                                                 readonly
  284.                                                 class="form-control form-control-sm"
  285.                                                 name="tgl_terbit"
  286.                                                 value="<?php 
  287.                                                     if ($_SESSION['tgl_terbit'] != null){
  288.                                                         echo $_SESSION['tgl_terbit'];
  289.                                                     } else {
  290.                                                         echo $_POST['tgl_terbit'] ;
  291.                                                     }
  292.                                                  ?>">
  293.                                         </div>
  294.                                         <!--lembar ijazah-->
  295.                                         <div class="form-group">
  296.                                             <label
  297.                                                 style="color: white; font-weight:bolder; letter-spacing: 2px;"
  298.                                                 id="lembar_ijazah">Lembar Ijazah :
  299.                                             </label>   
  300.                                             <input
  301.                                                     type="file"
  302.                                                     style="padding-left: 15px;"
  303.                                                     class="form-control form-control-sm"
  304.                                                     readonly
  305.                                                     name="lembar_ijazah"
  306.                                                     >                                        
  307.                                         </div>
  308.                                     </div>
  309.                                 </div>
  310.  
  311.                                 <div class="row">
  312.                                     <div class="col-md-12">
  313.                                         <div class="submit_btn">
  314.                                             <button
  315.                                                 type="submit"
  316.                                                 class="btn btn-primary btn-submit"
  317.                                                 style="font-size:22px; background: #081b30;">Submit</button>
  318.                                         </div>
  319.                                     </div>
  320.                                 </div>
  321.                             </form>