Question
Now that your application is properly functioning, modify the PHP portion of the such that if the user enters an incorrect login or password, a
Now that your application is properly functioning, modify the PHP portion of the such that if the user enters an incorrect login or password, a message as such is displayed to the user, via an echo statement. Also, modify the code such that the user will have only three attempts to log into the application. You can accomplish this by declaring a session variable named count that tracks the number of login attempts.
$login_name = "";
$login_password = "";
$success = "";
$error = "";
if ((isset($_POST["myName"]) && isset($_POST["myPassword"]))) {
$login_name = $_POST["myName"];
$login_password = $_POST["myPassword"];
if ($login_name == "sammy" && $login_password == "autumn") {
$url = "http://www.fye.com";
header("Location: $url");
}
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
session_start();
ob_start();
if (isset($_SESSION['count']))
$_SESSION['count'] = $_SESSION['count'] + 1;
else
$_SESSION['count'] = 1;
print "count = " . $_SESSION['count'];
if ($_SESSION['count'] <= 3) {
// existing PHP code
}
}
?>
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started