(1) Assignment description and-or files needed/Adding a Record to a Database Using a PHP Application.pdf Adding a Record to a Database Using a PHP Application There are two important steps involved...

1 answer below »
Use the assignment description PDF as your guide for this assignment. This will include all the code and files you will need. I have a lot of the code done and you can copy and paste the code I have on the PDF's on your end to speed up the process.


(1) Assignment description and-or files needed/Adding a Record to a Database Using a PHP Application.pdf Adding a Record to a Database Using a PHP Application There are two important steps involved with adding a record to a database table: 1. Create an HTML from to define data for the new record (client-side) 2. Create a server-side script to perform the following: ○ read input data ○ define an appropriate SQL statement ○ insert a new record to an existing table ○ display an appropriate message or error message Create a new folder named movieadmin in your htdocs folder. Copy the complete code found in "Using a Switch Statement to Process Different User Requests via a Single Server-side Script" zipped file that I’m linking and save it as index.php file in movieadmin folder. Step 1: Create an HTML Form to Define Data for the New Record (client-side) There are several important tasks involved with creating an HTML form: 1. Add a link/button to an existing page to display an HTML FORM . Example: The index.php file uses a switch statement to create the response. We can add a link similar to the following to request the server to display an HTML form:
Add New Member
The above link includes a key=value pair, mode=displaynewmemberform, which allows the server to identify the type of the request. Since we are using

  • elements to add a link using a

  • Answered Same DayNov 01, 2021

    Answer To: (1) Assignment description and-or files needed/Adding a Record to a Database Using a PHP...

    Anurag answered on Nov 02 2021
    113 Votes
    include("pdo_connect.php");
    ?>












    /* Check if the database connection is established. If not, exit the program. */
    if (!$db) {
    echo "Could not connect to the database";
    exit();
    }
    ?>



    Movie store




    // Define variables and assign their default values
    $mode = ""; // default value for the switch statement
    $parameterValues = null; // default values named parameters
    $pageTitle = ""; // define a title for each output
    $columns = array(); // define an array of column labels for a table header

    try {
    if (isset($_GET['mode'])) {
    $mode = $_GET['mode'];
    }

    switch ($mode) {
    case "members": // display a list of members
    // 1. define SQL statement
    $sql = "SELECT `firstName`, `lastName` FROM `members` order by `lastName`";

    // 2. Define values for named parameters. There are no parameters in this SQL statement. Use the default.

    // 3. Fetch result set
    $resultSet = getAll($sql, $db, $parameterValues);

    // 4. Display result
    $pageTitle = "List of Members";
    $columns = array("First Name", "Last Name"); // we will use a two-column table to display members
    displayResultSet($pageTitle, $resultSet, $columns);
    break;

    case "movies": // display a list of movies, based on the selected genre

    // 1. define SQL statement

    /* Note: We use two key/value pairs:
    mode - identifies the switch case
    genre - movie type
    If genre=all then display all the movies.
    If genre=Drama then display Drams type movies.
    Need two different SQL statements.
    We can use an...
    SOLUTION.PDF

    Answer To This Question Is Available To Download

    Related Questions & Answers

    More Questions »

    Submit New Assignment

    Copy and Paste Your Assignment Here