Mohon koreksi kesalahan syntax di code berikut

<?php
  require 'connection.php';
  checkLoginAtLogin();

  if (isset($_POST['btnLogin'])) {
  	$username = htmlspecialchars($_POST['username']);
  	$password = htmlspecialchars($_POST['password']);

  	$checkUsername = mysqli_query($conn, "SELECT * FROM user WHERE username = '$username'");
  	if ($data = mysqli_fetch_assoc($checkUsername)) {
  		if (password_verify($password, $data['password'])) {
  			$_SESSION = [
  				'id_user' => $data['id_user'],
  				'username' => $data['username'],
  				'id_jabatan' => $data['id_jabatan']
  			];
  			header("Location: index.php");
  		} else {
			setAlert("Password your insert is false!", "Check your Password BACK!", "error");
			header("Location: login.php");
	  	}
  	} else {
		setAlert("Username is not registered!", "Check your Username BACK!", "error");
		header("Location: login.php");
  	}
  }
?>
avatar Irfan225
@Irfan225

4 Kontribusi 0 Poin

Diperbarui 4 tahun yang lalu

1 Jawaban:

<pre>// mungkin kurang function session_start();</pre><div><br>penempatan function session start bisa dibawah&nbsp;</div><pre>require require 'connection.php'; session_start();</pre>

avatar rezanotalive
@rezanotalive

2 Kontribusi 0 Poin

Dipost 4 tahun yang lalu

Login untuk ikut Jawaban