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

x L 2017s CPS3740 Google Dr X Chegg Study l Guided soluti h Welcome to Eduardo\'

ID: 3792310 • Letter: X

Question

x L 2017s CPS3740 Google Dr X Chegg Study l Guided soluti h Welcome to Eduardo's proje YouTube On e- C Secure https:/ drive.google.com PDF 2017s CPS3740 project Open with Lumin PDF Project description: This is an individual project with 4 phases, and this is the first phase. You have to finish phase #1 in order to work on phase #2. You will design and implement an online Information system using MySQL HTML and (PHP or JAVA) You can refer to demo httplimckean eduCPS3240 Platform requirement: My Drive 1. You have to implement the projects on eve.kean.edu 2. You have to use MySQL to implement the database functions and store tables/data at imc.kean.edu. Your project CAN NOT be based the personal database running on your laptop or PC at home Phase #1 will require you to develop the following functions (total 100 points). 1. (10 pts) Create a CPS3740 project website on eve.kean.edu as shown in Figure 1. (4 pts) Permission mode 705 for your project folder and all PHP/HTML files. 1.1 (4 pts) Your project URL should be: htt eve kean edu PS3740 index.html 1.2 (2 pts) The main page should show your name and two links to project 1 and project 2. 1.3 2. (10 pts) When users click on Project 1 link, you should show the following features as shown in Figure 2. 2.1 (2 pts) Display welcome message with your name and Project 1 (2 pts) A link to list a users in the store. 2.2 (4 pts)Two textboxes for user to enter login ID and password, and a submit button. 2.3 2.4 (2 pts) You have to use POST method to implement the HTML FORM. Welcome to Austin Huangs CPS3740 project 1 C O imcke an edu/C Welcome to Austin CPS3740 Project Login ID: panda Password: Submit Figure 2. project 1 page Figure 1. main page 3. 10 pts) When users click on the link "list a users", a program should be called to list all users at CPS3740. Users table as shown in Figure 3 (3 pts) The output should be aligned for all columns using HTML

Explanation / Answer

Part 3:

<html><head></head><body>
<?php

$servername = ""; //Fill Server host
$username = ""; //Fill Database Username
$password = ""; //Fill Database Password
$dbname = "CPS3740"; //Fill Database Name

$conn = new mysqli($servername, $username, $password,$dbname);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
    echo "error";
}
$sql = "SELECT * FROM CPS3740.USERS";
$result = $conn->query($sql);
if ($result->num_rows > 0) { ?>
The users in the database:<br>
<TABLE border=1><TR><TD>ID<TD>login ID<TD>password<TD>Name<TD>Role<TD>address<TD>Zipcode<TD>State<TR>
<?php while($row = $result->fetch_assoc()) {


   echo "<TR><TD>" . $row['ID'] . "</TD>";
   echo "<TD>" . $row['login_ID'] . "</TD>";
   echo "<TD>" . $row['password'] . "</TD>";
   echo "<TD>" . $row['name'] . "</TD>";
   echo "<TD>" . $row['role'] . "</TD>";
   echo "<TD>" . $row['address'] . "</TD>";
   echo "<TD>" . $row['zipcode'] . "</TD>";
   echo "<TD>" . $row['state'] . "</TD></TR>";
}
?>
</table>
<?php
}
$conn->close();
?>
</body></html>

Part 4

<?php

$user = strtolower($_POST['username']);
$pass = $_POST['password'];


if(empty($user) && empty($pass))
{
   echo "Username and Password cannot be blank";
   die;
}
else if(empty($user))
{
   echo "Username cannot be blank";
   die;
}
else
{
   echo "Password cannot be blank";
   die;
}

$servername = ""; //Fill Server host
$username = ""; //Fill Database Username
$password = ""; //Fill Database Password
$dbname = "CPS3740"; //Fill Database Name

$conn = new mysqli($servername, $username, $password,$dbname);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
    echo "error";
}

$sql = "SELECT * FROM CPS3740.USERS WHERE lower(login_ID) = $user";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
   $sql = "SELECT * FROM CPS3740.USERS WHERE lower(login_ID) = $user AND password = $pass";
   $result1 = $conn->query($sql);
   if ($result1->num_rows > 0) {
       //Login Successful
   }
   else {
       echo "User exists, but pas does not match";
       die;
   }
}
else {
   echo "Login ID $user doesn't exists in the database";
   die;
}
?>