Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PART ONE For this assignment, create an html page that has a login form. The for

ID: 3826420 • Letter: P

Question

PART ONE

For this assignment, create an html page that has a login form. The form should have 3 input elements --

1. This should have a type text for the user to enter UserName

2. This should have a type password (like text except cannot see the text that is typed in), for the user to enter password.

3. Submit button (type submit, as we did in class on 2/6).

The form method should be set to POST and the action should be a php script (saved in a .php file).

The php script checks the userName and Password. If it is one of the following, then the page shows "You have successfully logged in!"

User Name   Password

elliez tr789ial

greatGuy        abc123

blogger 23seventeen23

If the userName and Password do not match the above, the the page shows "Sorry, wrong information has been entered"!

PART TWO

In your php script declares two arrays (or an associative array or a two dimensional array!) that holds 10 user names and 10 passwords. Using a loop, (if you want to use array functions instead of the loop, that is fine) check to see if the user input matches one of the ten pairs. Print the same messages as in PART ONE above. (We will cover this on Wednesday 2/8 or Wed 2/15)

PART THREE

In your php code above, place a comment that (in under four sentences) explains what type of error message a website gives when logon credentials are incorrect, and why this is the message.

Explanation / Answer

Part one

Login form in html

<html>

<head>

      <title>Login Demo</title>   

     </head>     

   <body>

      <h2>Enter Username and Password</h2>

         <?php

            $msg = '';

if (isset($_POST['login']) && !empty($_POST['username'])

               && !empty($_POST['password']))

{

If( ($_POST['username'] == 'elliez' && $_POST['password'] == ‘tr789ial’) ||

     ($_POST['username'] == 'greatGuy' && $_POST['password'] == ‘abc123’) ||        

($_POST['username'] == 'blogger' && $_POST['password'] == ‘23seventeen23’))

{

                 echo “You have successfully logged in!”;

              }

Else

{

                  $msg = “Sorry, wrong information has been entered!”;

               }

            }

         ?>     

         <form action = "#" method = "post">

            <h4><?php echo $msg; ?></h4>

            <table cellspacing="2" cellpadding="2" border="1">

<tr>

<td>

<label>Username</label>

</td>

<td>           

<input type = "text” name = "username" placeholder="Enter username">

</td>

</tr>

<tr>

<td>

<label>Password</label>

</td>

<td>

<input type="password" placeholder="Enter Password" name="password">

</td>

</tr>

<tr>

<td colspan="2" align="center">

<button type="submit">Submit</button>

</td>

</tr>

</table>           

</form>

</body>

</html>

Part three

In above php code, when logon credentials are incorrect it display the message "Sorry, wrong information has been entered!". It means entered username and password doest not match according to the condition. This activity is called authorisation. When required entered username and password are correct and both matches according to the condition then only login will be possible.