saya mau nampilin data user setelh login dengan menggunakan session. namun pas saya coba, yang tampil hanya cuma email, nama dan data lain tidak tampil. malahan ada error undefined index nama, bln, gender. tolong sayaaa
proseslogin.php
<?php
session_start();
require_once("connection.php");
$email = $_POST['email'];
$password = $_POST['password'];
$cekuser = mysql_query("SELECT * FROM user WHERE email = '$email'");
$jumlah = mysql_num_rows($cekuser);
$hasil = mysql_fetch_array($cekuser);
if($jumlah == 0) {
echo "<script>alert('Email belum terdaftar!'); window.location = 'index.php'</script>";
} else {
if($password > $hasil['password']) {
echo "<script>alert('Password Salah!'); window.location = 'index.php'</script>";
} else {
session_start();
$_SESSION['email'] = $_POST['email'];
$_SESSION['password'] = $_POST['password'];
header('location:index.php');
}
}
?>
index.php
<?php
if (session_status() == PHP_SESSION_NONE || session_id() == '') {
session_start();
}
require_once("connection.php");
include("lib_function.php");
?>
<--header-->
$email = $_SESSION['email'];
include "connection.php";
$sql = "select * from user where email='".$email."'";
$query = mysql_query($sql);
while($data = mysql_fetch_array($query)){
echo "Hello, " . $data['nama'] . " <br> " . $data['nname'] . " <br> " . $data['bln'] . " <br> " . $data['gender'] . " (" . $data['email'] . ").";
}