what the purpose of this script is. How the script carries out this purpose. You
ID: 3670755 • Letter: W
Question
what the purpose of this script is. How the script carries out this purpose. You should describe the code in blocks. So you want to say things like the if statement that goes from line x to line y defines what the program will do when condition z is true. Then, explain how those lines carry that purpose out.
<?php
require_once('../../include/proj1/proj1.php');
$pdo = connect();
if (!$pdo) {
die('Could not connect');
}
$loggedIn = FALSE;
if (count($_POST > 0)) {
$username = $_POST['username'];
$password = $_post
}
if (empty($_POST['username']) || empty($_POST['password'] ||
$loggedIn = FALSE) {
$displayBlock = “ <form action=”login.php” “ .
“method=”post”> ”;
$displayBlock .= “ </form> ”;
}
?>
<html>
<body>
<?php echo $displayBlock; ?>
</body>
</html>
Explanation / Answer
The purpose of the script is to check user login information. If user a valid then it respond to the user request.
The script the carries these purpose by checking user info. Let it discuss
<?php
require_once('../../include/proj1/proj1.php');
$pdo = connect();
if (!$pdo) {
die('Could not connect');
}
In the above block, Line 2 and line 3 includes the file that has the database connection information and connect () function. Line 3 uses that connect () function to connect to that database.
$loggedIn = FALSE;
if (count($_POST > 0))
{
$username = $_POST['username'];
$password = $_post
}
In the above block, it checks the login data. If it is valid then respond the user request. Example : “login is successfully”.
if (empty($_POST['username']) || empty($_POST['password'] ||
$loggedIn = FALSE) {
$displayBlock = “ <form action=”login.php” “ .
“method=”post”> ”;
$displayBlock .= “ </form> ”;
}
In this block, if condition checks that login information are not empty. If it is empty it will again display the same login page.
?>
<html>
<body>
<?php echo $displayBlock; ?>
</body>
</html>
In this block of code, Which statement be true it give the information along with that statement.
Example:if second “if statement” is true then it display the same login information.
I am giving a piece of code that will be execute if statement that goes from line x to line y defines what the program will do when condition z is true.
$loggedIn = FALSE;
if (count($_POST > 0)) {
$username = $_POST['username'];
$password = $_post
// check the value from the registration table//
The purpose the these code which I include is that if the user information are true which will be checked by table registration or whatever table you made for login process, it responses.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.