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

I need help with this assignment. please help. Please zip up the files and share

ID: 3719560 • Letter: I

Question

I need help with this assignment. please help.

Please zip up the files and share the link with me to download thank you!!!

Homework 10 CSIT 337 SPRING 2018 Create a MySQL database and call it csit101. Now let's create a table and call it administrators. This table contains three fields: adminlD, email, and password The following shows the sql file that generates the database and the required table. It also populates with two users whose email addresses are jgmail.com and kk@gmail.com - create and select the database DROP DATABASE IF EXISTS CSIT101 CREATE DATABASE CSIT101; USE CSIT101; CREATE TABLE administrators ( INT NOT NULL AUTO INCREMENT adminID email password VARCHAR(255) NOT NULL, firstName VARCHAR(255) NOT NULL, lastName VARCHAR(255) NOT NULL, PRIMARY KEY (adminlD) VARCHAR(255) NOT NULL, INSERT INTO administrators (adminlD, email, password, firstName, lastName) VALUES (1, 'jj@gmail.com', 'sesame', 'John', Johnson') (2, 'kk@gmail.com, 'password', 'Karen', 'King'); -- Create a user named super GRANT SELECT, INSERT, UPDATE, DELETE ON* TO super@localhost DENTIFIED BY 'super'; The main purpose for creating the user named super is for use in the creating of PDO. Recal that in order to create a PDO we need a user who have the credential to access the required database Although we don't need to grant full privileges to this user in order to run this lab, but we may use it later for other exercises

Explanation / Answer

index.php

============================================================================
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<?php
if (isset($_POST['username'])) {
      
        // Include the databas connection script
   include_once("connection.php");
  
   // Set the posted data from the form into local variables
    $usrname =$_POST['username'];
   $passwd = $_POST['password'];
  
   $sql = "SELECT email, password FROM administrators WHERE email = '$usrname'";
   $query = mysqli_query($conn, $sql);
   $row = mysqli_fetch_row($query);
  
   $dbUsname = $row[0];
   $dbPassword = $row[1];
  
   // Check if the username and the password they entered was correct
  
      
  
   if ($usrname == $dbUsname && $passwd == $dbPassword) {
  
       header("Location: welcome.php");
   } else {
       echo "<script>
                     $(document).ready(function(){
                           alert('arzed');
                         $('#p1').text('Error Invalid credential, you must correctly login to view this site.');
                     });
               
         
       </script>";
      
      
   }
}
?>

<!DOCTYPE html>
<html>
<head>
   <title>CSIT101 Log in System</title>
</head>
<body>
   <h1>Welcome to CSIT web site </h1>
   <p><h3>Please Login</h3></p>

   <form id="login" action="index.php" method="post">
       <table>
      
       <tr>
           <td>Email: </td>
           <td><input type="text" name="username" id="username"></td>
       </tr>
       <tr>
       <td>Password: </td>
       <td><input type="password" name="password" id="password"></td>
        </tr>
      
       <tr><td><input type="submit" value="Login" name="Submit" /></td></tr>

        </table>
        <p id="p1">You must login to view this site.</p>
   </form>

</body>
</html>

connection.php
=============================================================
<?php

define('DB_SERVER', 'localhost');
define('DB_USERNAME', 'super');
define('DB_PASSWORD', 'super');
define('DB_NAME', 'csit101');

/* Attempt to connect to MySQL database */
$conn = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);

// Check connection
if($conn === false){
    die("ERROR: Could not connect. " . mysqli_connect_error());
}
?>


welcome.php
==============================================================

<h1>Good job! Successfully login!!</h1>