edit - 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 edit.php

  1. <?php
  2.     include 'lib/library.php';
  3.  
  4.     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
  5.         $nis = $_POST['nis'];
  6.         $nama_lengkap = $_POST['nama_lengkap'];
  7.         $jenis_kelamin = $_POST['jenis_kelamin'];
  8.         $kelas = $_POST['kelas'];
  9.         $jurusan = $_POST['jurusan'];
  10.         $alamat = $_POST['alamat'];
  11.         $golongan_darah = $_POST['golongan_darah'];
  12.         $nama_wali = $_POST['nama_wali'];
  13.  
  14.         $sql = "UPDATE siswa SET nis = '$nis',
  15.                     nama_lengkap = '$nama_lengkap',
  16.                     jenis_kelamin = '$jenis_kelamin',
  17.                     kelas = '$kelas',
  18.                     jurusan = '$jurusan',
  19.                     alamat = '$alamat',
  20.                     golongan_darah = '$golongan_darah',
  21.                     nama_wali = '$nama_wali' WHERE nis = '$nis' ";
  22.  
  23.         $mysqli->query($sql) or die ($mysqli->error);
  24.  
  25.         header('location: index.php');
  26.     }
  27.     
  28.     $nis = $_GET['nis'];
  29.  
  30.     if (empty($nis)) header('location: index.php');
  31.  
  32.     $sql = "SELECT * FROM siswa WHERE nis = '$nis' ";
  33.     $query = $mysqli->query($sql);
  34.     $siswa = $query->fetch_array();
  35.  
  36.     if (empty($siswa)) header('location: index.php');
  37.  
  38.     include 'views/v_tambah.php';
  39. ?>
File Description
  • edit
  • PHP Code
  • 23 Oct-2019
  • 1.22 Kb
You can Share it: