first at all sorry for my bad English. I was a student for Programming and now I run into some Session problems. I know if you go through my code it's open for SQL Injection or some types of Cyber attack because I just learn to code in PHP. So here my problem
I have some problems when initializing my Session from Log In page. Here the code for login
LOGIN
<?php
include 'api.php';
session_start();
$msg = "";
if (isset($_POST['login'])) {
$email = mysqli_real_escape_string($con, $_POST['email']);
$pswd = mysqli_real_escape_string($con, $_POST['pswd']);
$SQL = "SELECT * FROM member WHERE email = '$email'";
$QuerySQL = mysqli_query($con, $SQL);
$FetchingData = mysqli_fetch_array($QuerySQL);
$VerifyingUserPswd = password_verify($pswd, $FetchingData['password']);
if (mysqli_num_rows($QuerySQL)) {
if ($VerifyingUserPswd == true) {
$email = $_SESSION['email'];
header("Location: index-session.php");
exit();
} else {
$msg = "Your credentials are inccorect !";
}
} else {
$msg = "Login Attempt Failed! Try again";
}
}
?>
and this is where i wanted to echo out the session name
INDEX SESSION
<?php
session_start();
$email = $_SESSION['email'];
include 'api.php';
$SessionInit = mysqli_query($con, "SELECT * FROM member WHERE email = '$email'");
$PaparSession = mysqli_fetch_array($SessionInit);
?>
Thank you in advance for your help. If there's any comments don't hesitate to leave it. I am a newbie. Much love from Malaysia