eror pada saat masuk ke halaman utama

Halo teman2 mau tnya nii say sudah buat form login. jd di form login saya tambahin session start, tapi pada saat login masuk ke menu utama eror..

login
<?php
  include 'koneksi/connection.php';
  error_reporting(0);
  session_start();

  if(isset($_POST['submit'])) {
    $email    = $_POST['email'];
    $password = md5($_POST['password']);

    $sql    = "SELECT * FROM tb_user WHERE email='$email' AND password='$password'";
    $result = mysqli_query($con, $sql);
    if($result->num_rows > 0) {
      $row = mysqli_fetch_assoc($result);
      $_SESSION['username'] = $row['username'];
      header("Location: daftar_buku.php");
    } else {
      echo "<script>alert('Woopps!! Email dan Password Salah.')</script>";
    }
  }

?>

Halaman utama setelah klik tombol login
<?php
 include 'koneksi/connection.php';
 include 'include/java.php';

 session_start();

?>

<?php echo "Welcome" . $_SESSION['username'] ; ?>

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>Perpustakaan</title>
  <link rel="shortcut icon" href="logo_rs.png" />
</head>

Hasil
Screenshot-2022-09-29-145941.jpgScreenshot 2022-09-29 145941.jpg


avatar novaje

@novaje

27 Kontribusi 3 Poin


Jawaban

Belum ada Jawaban, jadi yang pertama

Login untuk gabung berdiskusi