Question

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 ('foo', '$2y$10$IWDcVmWIHlx5nI5A.18gNOUDoJZgdfWJwFMamea9JaUK9M.iTx8g.');

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

authenticate.php

<?php

// 1. validate the form input (set $_SESSION['error'] if there is a problem)
// (make sure that neither form input is blank and use the w3schools Form
// Validation funtion to "scrub" all form data)
// 2. create a database connection (using the standard root user)
// 3. select the password from the users table (where the username came from
// the form)
// 4. use password_verify to see if the form password matches the hashed
// password from db: password_verify($pwdFromFrom, $dbPwd) returns a boolean
// 5. forward user to index.php
// 6. allow execution to continue and close db connection

?>

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

advice.php

<?php
// Make sure that only users who have been authenticated via the database
// can access this page.
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<!-- display your advice to future UNA students here -->
</body>
</html>

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

index.php

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title></title>

</head>

<body>

<?php

// 1. display the error message in the session (if any)

// 2. display either the user's name and a link to your advice page

// or the form below

?>

<form action="authenticate.php" method="post">

Username: <input type="text" name="user"><br>

Password: <input type="password" name="pwd"><br>

<input type="submit">

</form>

</body>

</html>

Homework Answers

Answer #1
<!DOCTYPE html>
<html>
<head>
        <title>Authentication</title>
</head>
<body>
        <form method="post" action="">
        <?php
$servername = "localhost";
$username = "foo";
$password = "bar";
$dbname = "advice";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

$sql = "SELECT password FROM users";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // output data of each row
    while($row = $result->fetch_assoc()) {
        echo "<br> password: ". $row["password"]. "<br>";
    }
} else {
    echo "0 results";
}

$conn->close();//Database connection close
?>
</form>
</body>
</html>
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
Modify this HTML code so that the user is prompted to enter a 4 digit identification...
Modify this HTML code so that the user is prompted to enter a 4 digit identification number. <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html> <html> <head> <meta charset="ISO-8859-1"> <title>Booking System</title> </head> <body> <h1>Welcome to the Conference Room Booking System</h1> <form action="MyServlet">    <input type="submit" value="Identification" /> </form> </body> </html>
<?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...
I am trying to make a contact form to give input on another browser window. I...
I am trying to make a contact form to give input on another browser window. I am only getting the php code. I am trying to figure out why it won't post. Her is my html and php files: <!DOCTYPE html> <html> <head> <title>Contact</title> <link rel="stylesheet" href="main.css"> </head> <body>    <h1>Contact Form</h1> <nav> <ul> <li><a href="index.html">Home</a></li> <li><a href="page2.html">My PodCast</a></li> <li><a href="page3.html">Contact Me</a></li> <li><a href="page4.html">Resources</a></li> <li><a href="addressbook.html">Address Book</a></li> <li>Contact Form</li> </ul> </nav> <center><h2>Please fill out form</h2> <div id='container'> <div id='header'></div> <center><h3>Contact</h3>...
<!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...
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...
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...
In the previous assessment, you used a static set of named variables to store the data...
In the previous assessment, you used a static set of named variables to store the data that was entered in a form to be output in a message. For this assessment, you will use the invitation.html file that you modified in the previous assessment to create a more effective process for entering information and creating invitations for volunteers. Rather than having to enter each volunteer and create an invitation one at a time, you will create a script that will...
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...
Java Script I need the code to produce these 3 output. I can only get it...
Java Script I need the code to produce these 3 output. I can only get it to produce input #3 I need it to produce the following: // Input #1: // http://www.example.com // Output // http://www.example.com // Input #2: // http://www.example.com?name=r2d2 // Output // http://www.example.com // name: r2d2 // Input #3: // http://www.example.com?name=r2d2&email=r2d2%40me.com&human=no // Output // http://www.example.com // name: r2d2 // email: [email protected] // human: no THIS IS WHAT I HAVE SO FAR: HTML <!DOCTYPE html> <html lang="en"> <head> <meta...
*To the guy who answered last time. You're not following the directions. Please follow specific directions...
*To the guy who answered last time. You're not following the directions. Please follow specific directions below.* Create a "web page" with the following components: An input field for the "number of rounds to play" The "number of remaining" rounds should also be displayed somewhere on the screen. A button to "Start" the game play. The function attached to this button can "setup" the rest of the game. For example: initialize counters, show/hide other components, etc. A set of buttons...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT