Data yang di input tidak tersimpan ke database dan tidah bisa tampil di web

mohon bantuanya, saya lagi belajar tentang menambahkan Tombol INSERT dan Menampilkan Hasil data serta menyimpannya di database

,

saya bingung kenapa ketika memcoba untuk memasukan data(pada gambar 1), ketika di klik tombol Save datanya, ada notif data sudah tersimpan akan tetapi data tidak masuk di tabel pada web dan di database

apakah ada yang salah pada script saya.. ?

Gambar 1

BeforeGambar 2

Gambar 4

After

page.php

<?php
    error_reporting(error_reporting() & ~E_NOTICE);
    include "config/koneksi.php";

if ($_GET['page']=="data_user"){
    include "page/user/data_user.php";
}
if ($_GET['page']=="create_user"){
    include "page/user/create_user.php";
}
elseif ($_GET['page']=="data_barang") {
    # code...
    include "page/barang/data_barang.php";
}
elseif ($_GET['page']=="data_transaksi") {
    # code...
    include "page/transaksi/data_transaksi.php";
}
?>

koneksi.php

<?php
global $mysqli;
$host="localhost";
$user="root";
$pass="";
$database="dbadmin";
$mysqli=new mysqli($host,$user,$pass,$database);
if (mysqli_connect_errno()) {
    # code...
    trigger_error("koneksi ke database gagal: " . mysqli_connect_error(), E_USER_ERROR);
}
?>

data_user.php

<!-- Content Header (Page header) -->
<section class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h1>DataTables</h1>
          </div>
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="#">Home</a></li>
              <li class="breadcrumb-item active">DataTables</li>
            </ol>
          </div>
        </div>
      </div><!-- /.container-fluid -->
    </section>

    <!-- Main content -->
    <section class="content">
      <div class="container-fluid">
        <div class="row">
          <div class="col-12">
            <div class="card">
              <div class="card-header">
                <h3 class="card-title">Data Admin dan User PA Banjarbaru</h3>
                <br>
                <button type="button" class="btn btn-success" data-toggle="modal" data-target="#modal-default">
                  TAMBAH USER
                </button>
              </div>
              <!-- /.card-header -->
              <div class="card-body">
                <table id="example1" class="table table-bordered table-striped">
                  <thead>
                      <tr>
                          <th>NO</th>
                          <th>IDUSER</th>
                          <th>NAMA USER</th>
                          <th>STATUS</th>
                      </tr>
                  </thead>
                  <Tbody>
                      <?php
                            $no = 0;
                            $admin=$mysqli->query("SELECT * FROM dbuser");
                            while ($m=mysqli_fetch_array($admin)) {
                                # code...
                            $no++;
                      ?>
                      <tr>
                          <th><?php echo $no ; ?></th>
                          <th><?php echo $m['iduser']; ?></th>
                          <th><?php echo $m['namauser']; ?></th>
                          <th><?php echo $m['status']; ?></th>
                      </tr>
                            <?php } ?>
                  </Tbody>
                </table>
              </div>
              <!-- /.card-body -->
            </div>
            <!-- /.card -->
          </div>
          <!-- /.col -->
        </div>
        <!-- /.row -->
      </div>
      <!-- /.container-fluid -->
    </section>
    <!-- /.content -->

    <!-- MODEL FORM TOMBOL TAMBAH -->
    <div class="modal fade" id="modal-default">
        <div class="modal-dialog">
          <div class="modal-content">
            <div class="modal-header">
              <h4 class="modal-title">Form Tambah User</h4>
              <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                <span aria-hidden="true">&times;</span>
              </button>
            </div>
            <div class="modal-body">
              <!-- form start -->
              <form role="form" method="post" action="index.php?page=create_user">
                <div class="card-body">
                  <div class="form-group">
                    <label for="exampleInputEmail1">ID USER</label>
                    <input type="text" class="form-control" nama="iduser" placeholder="Masukan User ID">
                  </div>
                  <div class="form-group">
                    <label for="exampleInputEmail1">NAMA</label>
                    <input type="text" class="form-control" nama="nama" placeholder="Masukan Nama">
                  </div>
                  <div class="form-group">
                    <label for="exampleInputEmail1">STATUS</label>
                    <input type="text" class="form-control" nama="status" placeholder="Status Anda">
                  </div>
                  <div class="form-group">
                    <label for="exampleInputPassword1">Password</label>
                    <input type="password" class="form-control" nama="pswd" placeholder="Password">
                  </div>
                </div>
                <!-- /.card-body -->

                <div class="card-footer">
                  <button type="submit" class="btn btn-primary">Save</button>
                </div>
              </form>
            </div>
            <div class="modal-footer justify-content-between">
            </div>
          </div>
          <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
      </div>
      <!-- /.modal -->

create_user.php

<?php
$id = $_POST['iduser'];
$name = $_POST['nama'];
$stat = $_POST['status'];
$pswd = $_POST['pswd'];

$mysqli->query("INSERT * INTO tbuser VALUE('$id','$name','$stat','$pswd')");

    echo "<script>alert('Data berhasil ditambahkan')</script>";
    echo "<script type='text/javascript'> document.location = 'index.php?page=data_user'; </script>";
?>
avatar ahmadirawan
@ahmadirawan

1 Kontribusi 0 Poin

Diperbarui 3 tahun yang lalu

1 Jawaban:

<div>query insert gak perlu ada tanda "*". jadinya begini</div><pre>INSERT INTO tbuser VALUES('$id','$name', '$stat', '$pswd')</pre>

avatar sonypiay
@sonypiay

12 Kontribusi 8 Poin

Dipost 3 tahun yang lalu

Login untuk ikut Jawaban