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

}

}

?>

Login Screen

First Name


Password


Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!