Question

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

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 a two dimensional array!) that holds 10 user names and 10 passwords. Using a loop, 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

Read: http://security.stackexchange.com/questions/17816/username-and-or-password-invalid-why-do-websites-show-this-kind-of-message-i

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.

Homework Answers

Answer #1

PART ONE

HTML PAGE

<html>
<body>
<form id='login' action='login.php' method='post' accept-charset='UTF-8'>
<fieldset >
<legend>Login</legend>
<input type='hidden' name='submitted' id='submitted' value='1'/>
<label for='username' >UserName*:</label>
<input type='text' name='username' id='username' maxlength="50" />
<label for='password' >Password*:</label>
<input type='password' name='password' id='password' maxlength="50" />
<input type='submit' name='Submit' value='Submit' />
</fieldset>
</form>
</body>
</html>

login.php FILE

<?php

function Login()
{

if(empty($_POST['username']))
{
$this->HandleError("UserName is empty!");
return false;
}
if(empty($_POST['password']))
{
$this->HandleError("Password is empty!");
return false;
}
$username = trim($_POST['username']);
$password = trim($_POST['password']);
if( ($username == 'elliez' && $password == 'tr789ial') ||
   ($username == 'greatGuy' && $password == 'abc123') ||
   ($username == 'blogger' && $password == '23seventeen23'))
{
echo "You have successfully logged in!";
return true;
}
echo "Sorry, wrong information has been entered!";
return false;
}

?>

PART TWO

Change only your login.phph file to use associative array instead of hard-coding the username and password combination in your code.

<?php

function Login()
{

   $logins = array(
'username1' => 'password1',
'username2' => 'password2',
'username3' => 'password3',
);

if(empty($_POST['username']))
{
$this->HandleError("UserName is empty!");
return false;
}
if(empty($_POST['password']))
{
$this->HandleError("Password is empty!");
return false;
}
$username = trim($_POST['username']);
$password = trim($_POST['password']);
if( ! isset($logins[$username]) or $logins[$username] != $password)
{
echo "Sorry, wrong information has been entered!";
return false;
}
echo "You have successfully logged in!";
return true;
}

?>

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Create an application that will give valuable advice to future students from someone (you!) who is...
Create an application that will give valuable advice to future students from someone (you!) who is close to graduation. However, only end-users who have their credentials validated against the database (which uses encrypted passwords) are allowed entry. ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- advice_ddl.sql CREATE DATABASE advice; USE advice; CREATE TABLE users ( id int primary key auto_increment, username varchar(255), password varchar(255) ); -- insert a row into the users table: -- username = foo -- password = bar INSERT INTO users (username, password) VALUES...
html/php 1. Create an html page (with an html file ending) that contains a form. This...
html/php 1. Create an html page (with an html file ending) that contains a form. This form will accept a number from the user. The form will then send this number to the assignment3.php program by using either GET or POST. 2. The assignment3.php program will read the value in the textbox and place it into the variable "myvalue". The program will then use either a switch statement or IF/THEN/ELSE statement to determine if the value entered is within 10...
<?php    if(isset($_GET['submit'])){ //sanitize the input        /* Check the error from the input: if...
<?php    if(isset($_GET['submit'])){ //sanitize the input        /* Check the error from the input: if input from user is empty -> get an error string variable if input is not empty -> use preg_match() to match the pattern $pattern = "/^[1-9][0-9]{2}(\.|\-)[0-9]{3}(\.|\-)[0-9]{4}$/"; -> if it's a matched, get a success string variable */           } ?> <!doctype html> <html lang="en"> <head> <!-- Required meta tags --> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <!-- Bootstrap CSS --> <link...
Java Servlet Program that represents an authentication platform where user will authenticate their username, passwordand usercode....
Java Servlet Program that represents an authentication platform where user will authenticate their username, passwordand usercode. After successful authentication, a message will be printed on the screen. All the wrong use of credentials will result in error that you will handle and there will also be a message displayed on the screen. Following are minimum guidelines: 1. The front end should have a background color and a heading like “User authentication System”. 2. It should have a text field with...
8- Develop a personal web page for yourself using HTML, CSS, and Javascript Use the following...
8- Develop a personal web page for yourself using HTML, CSS, and Javascript Use the following HTML tags to design your webpage <h1>…</h1> , <h3>… </h3> , <h6>… </h6> , <p>…</p> , <b> …</b> , <i>…</ i>, <a…..> </a>, <img…..> , <table>….</table> , <div> …</div>, <form>…</ form>, <input type=“text”>, and <input type=“submit”> Use an external css to change the default style of your webpage. You must use at least one element selector, one id selector, and one class selector Using...
The course project contains two parts. Part one involves designing and implementing login/logout and session controls...
The course project contains two parts. Part one involves designing and implementing login/logout and session controls for database users on the Web. Part two involves designing and implementing a “Student Enrollment Information System” for these users. This enrollment system will allow a student to query his/her course information as well as allow them to enroll in courses through a Web interface. Administrators of the system will be able to manage and maintain the student enrollment information system through a Web...
You have one Question, Which have four parts, 1st... PHP scriptIn a HTML document, use PHP...
You have one Question, Which have four parts, 1st... PHP scriptIn a HTML document, use PHP to obtain the following :The user will write a sentence as a value of a predefined variable.The output should look like this :The sentence you entered is :This is my sentenceIt is composed of :• 4 different words• 19 characters (including spaces)Note : Your program should make sure the final output is in lower case with the first letter in upper case. 2nd... PHP...
Please linked both files. For this assignment you need to create a ToDo list using Javascript,...
Please linked both files. For this assignment you need to create a ToDo list using Javascript, along with HTML and CSS. Begin by creating a HTML page called todo.html. Then create a Javascript file called todo.js and link it in to the HTML page using a script tag. All Javascript for the assignment must be in the separate file. (For CSS, feel free to include styles in a style block at the top of the HTML page, or to link...
For this assignment you'll be creating an application that has the user input a subtotal, tax...
For this assignment you'll be creating an application that has the user input a subtotal, tax rate and tip percentage and then displays the sales tax, tip amount and the total. You'll use JQuery instead of the getElementByX functions AND you will display all messages on the page (no alert or prompt boxes) The starter file is based off of the Lab 2 sales_tax application. Feel free to borrow code from your lab solution but realize you will need to...
<!doctype html> <html lang=”en”>   <head>     <title>Principal Calculation Form</title>     <meta charset="utf-8"/>         
<!doctype html> <html lang=”en”>   <head>     <title>Principal Calculation Form</title>     <meta charset="utf-8"/>                   <script src="code.js"></script>   </head>      <body onload="setFocus();">     <div class="container">                                       <div class="main">                                                                                <form action="#" method="post" name="form_name" id="form_id" class="form_class" >                                                                           <h2>--Principal Loan Form--</h2>                                                                                                                                                      <h5>Disclaimer: This software by no mean will precisely predict your mortgage through your lender company.  This Software will only assume the four items below in order to make an educated guess or prediction to your exact mortgage interests amount and the duration of your loan from your lender. <img...