In my case I've got in $_SESSION['login_attempts'] the same value all the time. It seems the global variable is restablished all the time I execute the submit,. How can I keep the value of this variable? Thank you.
Hello, i have a session_start() at the top of my code but it still shows an error of the following: Warning: Undefined array key "login_attempts" in ...... What could be the problem?
@@moodzc945 You need to put the following condition: if (isset($_SESSION["login_attempts"])) Also, make sure you are calling session_start() at the page where you are saving the value in this variable.
i tried many different ways to fix the Undefined array key "login_attempts" error but it is still not working. can you tell me how to fix this error please
Hello, you need to add the @ symbol at the beginning of your code. For example: @$_SESSION['login_attempts'] += 1; This is not an error, it is a warning that we have received because the session named login_attempts has not been used yet.
I am facing the problem Notice: Undefined index: login_attempts in C:\xampp\htdocs\web\user\login.php on line 35 I have called session_start at the top of file How to fix it? Help plz
@@AdnanAfzal565 hello, i also have the same problem and I already tried isset($_SESSION["login_attempts"]). but after 2 attempt the login button still appear and not disable. can I know what can I do?
it work fine im not sure if youre code is right this is what i did: after post password i used lock out commands like this: $lockout_time = isset($_SESSION['lockout_time']) ? $_SESSION['lockout_time'] : 0; $login_attempts = isset($_SESSION['login_attempts']) ? $_SESSION['login_attempts'] : 0; then use if statement to check: if (time() - $lockout_time < 30) { echo " You have attempted to log in too many times. Please try again in " . (30 - (time() - $lockout_time)) . " seconds. "; } else { add remaindier code here and after then: } else { $login_attempts++; if ($login_attempts >= 3) { $_SESSION['lockout_time'] = time(); } $_SESSION['login_attempts'] = $login_attempts; echo " You have entered the invalid username or a password, try again "; echo "Check"; } }
this is what i did: $lockout_time = isset($_SESSION['lockout_time']) ? $_SESSION['lockout_time'] : 0; $login_attempts = isset($_SESSION['login_attempts']) ? $_SESSION['login_attempts'] : 0; if (time() - $lockout_time < 30) { echo " You have attempted to log in too many times. Please try again in " . (30 - (time() - $lockout_time)) . " seconds. ";
session can be deleted, so timeout can be avoided
In my case I've got in $_SESSION['login_attempts'] the same value all the time. It seems the global variable is restablished all the time I execute the submit,. How can I keep the value of this variable? Thank you.
May be you are not incrementing the value of this variable.
Hello, i have a session_start() at the top of my code but it still shows an error of the following:
Warning: Undefined array key "login_attempts" in ......
What could be the problem?
it seems like i should initialize the $_SESSION["login_attempts"] but how?
@@moodzc945 You need to put the following condition:
if (isset($_SESSION["login_attempts"]))
Also, make sure you are calling session_start() at the page where you are saving the value in this variable.
did you initialized $_session["login_attempts"].if yes where you used that
Please create this functionality with angular
I'm having an error Undefined array key "login_attempts". Why??
You need to use:
session_start();
if (isset($_SESSION["login_attempts"]))
{
// code goes here
}
@@AdnanAfzal565 which codes goes there?
@@AustinChris_ That will be at the top of your file.
@@AdnanAfzal565 I did that, now I'm having an error of undefined index: login_attempts
i have error undefined array key login attempts what does that mean?
Make sure you are running session_start() at the top.
@@AdnanAfzal565 hello thank you for replying yes i have session start at the top
@@yeojsoriano8095 You can do iif (sset($_SESSION["login_attempts"])) {
//
}
where is login_attempts is defined?
It is created here: ua-cam.com/video/tH7dzGnrSI8/v-deo.html
I used the same code used by you... but got Notice: Undefined index: login_attempts in C:\xampp\htdocs\arc\attempt.php on line 61.. Please guide me.
It means your _SESSION variable does not have that index. Make sure you are calling session_start at the top of file.
I do get these warnings but the code does work. What could be the reason ? Thank you
What warnings you are you getting ?
i tried many different ways to fix the Undefined array key "login_attempts" error but it is still not working. can you tell me how to fix this error please
You need to use the
if(isset($_SESSION["login_attempts"])) {
}
Hello, you need to add the @ symbol at the beginning of your code. For example: @$_SESSION['login_attempts'] += 1;
This is not an error, it is a warning that we have received because the session named login_attempts has not been used yet.
How to do the same task in Node js & MySQL ??
Node JS also has a module named “express-session”. Mysql queries will remain same.
@@AdnanAfzal565 what is the R8 approach to do that pls help 🙏
I am not getting any clue using express-session
I am facing the problem
Notice: Undefined index: login_attempts in C:\xampp\htdocs\web\user\login.php on line 35
I have called session_start at the top of file
How to fix it? Help plz
Make sure you are calling isset($_SESSION["login_attempts"]) before using the session.
@@AdnanAfzal565 hello, i also have the same problem and I already tried isset($_SESSION["login_attempts"]). but after 2 attempt the login button still appear and not disable. can I know what can I do?
Make sure you are calling session_start(); at the top of your file.
@@AdnanAfzal565 you are not called isset($_SESSION["login_attempts"]) in your source code. why it works?
@@meseleawulachew8059 Because in my browser it was previously being saved.
add countdown with the value
Can you please elaborate ?
@@AdnanAfzal565 when you are showing the time 10 sec please add a count down like 10 9 8 7 every 1 sec it will be better
Okay. Got it. Thank you for the suggestion.
time function is not working
What error are you having ?
Well Explained.
Thanks.
dont work
What error you are getting ?
it work fine im not sure if youre code is right this is what i did:
after post password i used lock out commands like this:
$lockout_time = isset($_SESSION['lockout_time']) ? $_SESSION['lockout_time'] : 0;
$login_attempts = isset($_SESSION['login_attempts']) ? $_SESSION['login_attempts'] : 0;
then use if statement to check:
if (time() - $lockout_time < 30) {
echo " You have attempted to log in too many times. Please try again in " . (30 - (time() - $lockout_time)) . " seconds. ";
} else {
add remaindier code here and after then:
} else {
$login_attempts++;
if ($login_attempts >= 3) {
$_SESSION['lockout_time'] = time();
}
$_SESSION['login_attempts'] = $login_attempts;
echo " You have entered the invalid username or a password, try again ";
echo "Check";
}
}
this is what i did:
$lockout_time = isset($_SESSION['lockout_time']) ? $_SESSION['lockout_time'] : 0;
$login_attempts = isset($_SESSION['login_attempts']) ? $_SESSION['login_attempts'] : 0;
if (time() - $lockout_time < 30) {
echo " You have attempted to log in too many times. Please try again in " . (30 - (time() - $lockout_time)) . " seconds. ";
} else {
$result = mysqli_query($con, "SELECT * FROM users WHERE Email='$email'");
$row = mysqli_fetch_assoc($result);
if ($row && password_verify($password, $row['Password'])) {
$_SESSION['valid'] = $row['Email'];
$_SESSION['username'] = $row['Username'];
$_SESSION['age'] = $row['Age'];
$_SESSION['id'] = $row['Id'];
header("Location: home.php");
exit;
} else {
$login_attempts++;
if ($login_attempts >= 3) {
$_SESSION['lockout_time'] = time();
}
$_SESSION['login_attempts'] = $login_attempts;
echo " Wrong Username or Password ";
echo "Go Back";
}
}