0

Please correct the two syntax errors after " exit; " on line 8 and 16.

code below:

<?php
$bad_login_limit = 3;
$lockout_time = 600;
$first_failed_login = failed_login_count; // retrieve from DB

if(     ($failed_login_count >= $bad_login_limit)  && (time() - ($first_failed_login) < $lockout_time) ) 
    { echo "You are currently locked out." ; } exit; // or return, or whatever.
 else if( /* login is invalid */ ) {
  if( time() - $first_failed_login > $lockout_time ) {
    // first unsuccessful login since $lockout_time on the last one expired
    $first_failed_login = time(); // commit to DB
    $failed_login_count = 1; // commit to db
  } else {
    $failed_login_count++; // commit to db.
  }
  exit; // or return, or whatever.
} else {
  // user is not currently locked out, and the login is valid.
  // do stuff
}
?>
5
Contributors
6
Replies
30
Views
3 Years
Discussion Span
Last Post by almostbob
0

If you indented and structured your conditional blocks properly, you could correct it yourself. If you do that, the issue should be obvious.

0

The best solution is already written, once you see it too, then this or anything like it will generate the headslap moment for you that is does for others,
to help you complete the self-help described, get a code-completing editor
Many basic editors, notepad replacements, programmer's editors, and whatever else the editor may be called, have code completion built in.

When you leave out some neccessary element, a closure, a semi-colon, a quote, or place elements in position that creates a headslap,
the code changes color at that point determined by the editor to require a code change,
to demonstrate there is something amiss

I use notepad++portable and notepad2-portable, you may choose any that appeal, but any will help solve this problem

headslap: noun: extreme facepalm

Edited by almostbob

0

<Grin> to the OP
it has been
hinted,
about proper indenting and structure to make it easier,
about closure positions,
about exit being outside the code block

now if you can't see that because of the poor code formatting,
there are exits outside the code block where they should be, and you have to move the block closure so the exit is inside the closure, then, . . .
doh headslap moment
dunno what else to write

Edited by almostbob

0

another hint, the errors are before }exit;, and should be after exit;}

Edited by almostbob

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.