Question

In this assignment you will combine HTML, PHP, and SQL in order to create a web...

In this assignment you will combine HTML, PHP, and SQL in order to create a web form that allows a manager to add films to the sakila database. You will also create a method to allow the manager to view a list of all films along with their related information, and a list of actors in the movies.

Task 1

  1. Create an initial HTML page titled manager.html with 2 buttons. The first button will be labeled “View Films”, and the second button will be labeled “Add Film”. The first button should link to a file titled view_films.php. The second button should link to a file titled add_film.html.
  2. Create the view_films.php file. This file should generate an html page that contains a table that lists all of the flims in the film table from the sakila database. You should list the following information about each film: title, description, rating, rental duration, rental_rate, length, category, and a list of actor names (first, last) that appear in the movie. This page should have a button that returns you to the manager.html page. The last column in your table will be a string containing all the actor names … you do not need a different cell for each actor name because the number of actors in each movie is not the same. Use a comma to separate actor names. (I suggest working on adding the actor names last, as this is the most complicated step). You can also use the Film “title” as the key to an associative array since each title is unique.

Task 2

  1. Create the add_film.html file. It should have a form with text boxes to input the following information about a new flim: title, description, release_year, language_id, rental_duration, rental_rate, length, replacement_cost, rating, special_features. “rating” should be a drop down box with only the following values: G, PG, PG-13, R, NC-17. “special features” should be a drop down box with only the following values: Trailers, Commentaries, Deleted Scenes, Behind the Scenes. You do not need to do error checking on the input (i.e. verify that cost is a number), but be aware that if you don’t enter the correct data type your query may fail. So use good data for testing. You will need two buttons on this page, save and cancel. The save button will need to insert the employee information into the database as described below (by linking to a file titled add_film.php), display a message stating whether the query was successful or not, and display button to return to the manager.html page. The cancel button will simply need to return to the manager.html page.

Task 3

  1. Create the add_film.php file.   Here is a sample query that does the work for you: INSERT INTO sakila.film (title,description,release_year,language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features) VALUES ('1st Grade FBI Agent','An undercover FBI agent must pretend to be a 1st grade teacher to catch the bad guy',2014,2,5,4.99,123,20.99,'PG-13','trailers');
  2. You will need to use the query above as a guide to use inputs from the $_POST array to insert into the database. Your add_film.php page should display success if the film was added, or an error message if the insertion failed. You should also have a button linking back to the manager.html page.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

manager.html

<!DOCTYPE html>
<html>
<head>
   <title>Film data</title>
   <link rel="stylesheet" type="text/css" href="bootstrap.min.css">

<!--Please download bootstrap.min.css form internet -->
</head>
<body>
   <div class="container" style="margin-top: 50px;">
       <div class="row">
           <div class="col-md-3"></div>
           <div class="col-md-3">
               <a href="view_films.php" class="btn btn-primary">View Films</a>
           </div>
           <div class="col-md-3">
               <a href="add_film.html" class="btn btn-primary">Add film</a>
           </div>
       </div>
   </div>
</body>
</html>

view_films.php

<!DOCTYPE html>
<html>
<head>
   <title>Films list</title>
   <link rel="stylesheet" type="text/css" href="bootstrap.min.css">
</head>
<body>
   <div class="container">
       <div class="row">
           <?php
               $conn = mysqli_connect("localhost","root","your_password","sakila");
               $sql = "SELECT * FROM film";
               $query = mysqli_query($conn,$sql);
               $total = mysqli_num_rows($query);
               $res='';
               if($total>0){?>
               <table class="table table-striped table-bordered table-hover table-checkable order-column">
                   <thead>
                       <tr>
                           <th>Title</th>
                           <th>Description</th>
                           <th>Release Year</th>
                           <th>Language Id</th>
                           <th>Rental Duration</th>
                           <th>Rental rate</th>
                           <th>Lenght</th>
                           <th>Replacement cost</th>
                           <th>Rating</th>
                           <th>Special Features</th>
                           <th>Actors</th>
                       </tr>
                   </thead>
                   <?php
                   while($row=mysqli_fetch_assoc($query)){
                       ?>
                       <tr>
                           <td><?php echo $row["title"];?></td>
                           <td><?php echo $row["description"];?></td>
                           <td><?php echo $row["release_year"];?></td>
                           <td><?php echo $row["language_id"];?></td>
                           <td><?php echo $row["rental_duration"];?></td>
                           <td><?php echo $row["rental_rate"];?></td>
                           <td><?php echo $row["length"];?></td>
                           <td><?php echo $row["replacement_cost"];?></td>
                           <td><?php echo $row["rating"];?></td>
                           <td><?php echo $row["special_features"];?></td>
                           <td><?php echo $row["actors"];?></td>
                       </tr>
                       <?php
                   }
               }
               else{
                   echo "<h1>There no records found</h1>";
               }
           ?>
       </div>
   </div>
</body>
</html>

add_film.html

<!DOCTYPE html>
<html>
<head>
   <title>Adding film</title>
   <link rel="stylesheet" type="text/css" href="bootstrap.min.css">
   <style type="text/css">
       .name{
           font-size: 20px;
           color:blue;
           font-weight: bold;
           font-family: sans-serif;
           margin-top: 2px;
       }
   </style>
   <script type="text/javascript">
       function validate(){
           var release_year = $("#release_year").val();
           var language =$("#language").val();
           var rental_d = $("#rental_d").val();
           var rental_r = $("#rental_r").val();
           var length =$("#length").val();
           var repla_cost = $("#repla_cost").val();
           if(!isNaN(release_year) && !isNaN(language) && !isNaN(rental_r) && !isNaN(rental_d) && !isNaN(length) && !isNaN(repla_cost)){
               return true;
           }
           else{
               $("#error").slideDown();
               $("#error").slideUp(4000);
               return false;
           }
       }
   </script>
</head>
<body>
   <div class="container" style="margin-top: 50px;">
       <div class="alert alert-danger" style="display:none" id="error"><center><b>**Please Filled Out All the details**</b></center></div>
       <form action="add_film.php" method="post" onsubmit="return validate()">
           <center>
               <div class="form-group">
                   <h1>Adding film</h1>
                   <table>
                       <tr>
                           <td><p class="name">Title: </p> </td>
                           <td><input type="text" name="title" class="form-control" required=""></td>
                       </tr>
                       <tr>
                           <td><p class="name">Description: </p> </td>
                           <td><input type="text" name="desc" class="form-control" required=""></td>
                       </tr>
                       <tr>
                           <td><p class="name">Release Year: </p> </td>
                           <td><input type="text" name="release_year" class="form-control" required="" id="release_year"></td>
                       </tr>
                       <tr>
                           <td><p class="name">Language id: </p> </td>
                           <td><input type="text" name="language" class="form-control" required="" id="language"></td>
                       </tr>
                       <tr>
                           <td><p class="name">Rental Duration: </p> </td>
                           <td><input type="text" name="rental_d" class="form-control" required="" id="rental_d"></td>
                       </tr>
                       <tr>
                           <td><p class="name">Rental Rate: </p> </td>
                           <td><input type="text" name="rental_r" class="form-control" required="" id="rental_r"></td>
                       </tr>
                       <tr>
                           <td><p class="name">Length: </p> </td>
                           <td><input type="text" name="length" class="form-control" required="" id="length"></td>
                       </tr>
                       <tr>
                           <td><p class="name">Replacement Cost: </p> </td>
                           <td><input type="text" name="repla_cost" class="form-control" required="" id="repla_cost"></td>
                       </tr>
                       <tr>
                           <td><p class="name">Rating: </p> </td>
                           <td>
                               <select type="text" name="rating" class="form-control">
                                   <option value="g">G</option>
                                   <option value="pg">PG</option>
                                   <option value="pg13">PG-13</option>
                                   <option value="r">R</option>
                                   <option value="nc17">NC-17</option>
                               </select>
                           </td>
                       </tr>
                       <tr>
                           <td><p class="name">Special features: </p> </td>
                           <td>
                               <select name="spe_fea" class="form-control">
                                   <option value="trailers">Trailers</option>
                                   <option value="Commentaries">Commentaries</option>
                                   <option value="del_sce">Deleted Scenes</option>
                                   <option value="behind_sce">Behind the Scenes</option>
                               </select>
                           </td>
                       </tr>
                       <tr>
                           <td><p class="name">Actors: </p></td>
                           <td><input type="text" name="actors" class="form-control" placeholder="Actors name divided by ,"></td>
                       </tr>
                       <tr>
                           <td><button class="btn btn-primary" name="sumbit" type="submit">Sumbit</button></td>
                           <td><a href="manager.html" class="btn btn-primary">Cancel</a></td>
                       </tr>
                   </table>
               </div>
           </center>
       </form>
   </div>
</body>
</html>

add_film.php

<link rel="stylesheet" type="text/css" href="bootstrap.min.css">
<?php
   $conn = mysqli_connect("localhost","root","your_password","sakila");
   if($_SERVER["REQUEST_METHOD"]=="POST"){
       $file_title = $_POST["title"];
       $description = $_POST["desc"];
       $rel_year = $_POST["release_year"];
       $lan_id=$_POST["language"];
       $ren_dur = $_POST["rental_d"];
       $ren_rate =$_POST["rental_r"];
       $len = $_POST["length"];
       $rep_cost = $_POST["repla_cost"];
       $film_rat = $_POST["rating"];
       $file_features = $_POST["spe_fea"];
       $actors = $_POST["actors"];
       $sql = "INSERT INTO film(title,description,release_year,language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,actors) values('".$file_title."','".$description."','".$rel_year."','".$lan_id."','".$ren_dur."','".$ren_rate."','".$len."','".$rep_cost."','".$film_rat."','".$file_features."','".$actors."')";
       //$query = mysqli_query($conn,$sql);
       if(mysqli_query($conn,$sql)){
           echo '<script>alert("Film data successfully inserted");</script><center><a href="manager.html" class="btn btn-primary">Goto Back</a></center>';
       }
       else{
           echo "<script>alert('Erro in insertion');window.location='add_film.html';</script>";
       }
   }
?>

Add a comment
Know the answer?
Add Answer to:
In this assignment you will combine HTML, PHP, and SQL in order to create a web...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • SQL Queries – in this assignment you will be asked to create several SQL queries relating...

    SQL Queries – in this assignment you will be asked to create several SQL queries relating to the Sakila database that we installed in class. You may freely use DBeaver to create these queries, but I will expect your solution to show me the SQL code to answer or complete the tasks below. Write a query that produces the last name, first name, address, district, and phone number for every customer in the customer table. (You don’t need to include...

  • Create web pages for your database using PHP. You should have one page that will return...

    Create web pages for your database using PHP. You should have one page that will return all the information from the database. You should create additional pages that will allow you to do various queries of your database. You should be able to retrieve and insert data; also include functionality to delete data from your database. Create an html form that will allow you to enter in new information for the database. The information should be handled by a PHP...

  • Place an e-iall k t0 yuIJU 6. Create a web page about your favorite sports team...

    Place an e-iall k t0 yuIJU 6. Create a web page about your favorite sports team with a two-column table that list the positions and starting players. Use embedded CSS to style the table border, back ground color, and center the table on the web page. Place an e-mail link to yourself n the web page. Save the file as sport8.html. 7. Create a web page about your favorite movie that uses a two-column table contain- ing details about the...

  • PHP Programming In this project, you will create a Web page that allows visitors to your...

    PHP Programming In this project, you will create a Web page that allows visitors to your site to sign a guest book that is saved to a database. Create a new document in your text editor and type the <!DOCTYPE> declaration, <html> element, document head, and <body> element. Use the strict DTD and “Guest Book” as the content of the <title> element. Add the following text and elements to the document body: <h2>Enter your name to sign our guest book</h2>...

  • already created table now need php and html Write SQL statements to delete the above table....

    already created table now need php and html Write SQL statements to delete the above table. 3. PHP with html Write the html code to allow a user to enter a SUP_ID from the sunnysdiner database available on the same scrver. Then write the separate file with PHP script should display all the supplier's information from the supplier table with proper error handling. html file: a) use sunnysdiner; CREATE TABLE supplier ( food_item varchar(30) not null primary ley, SUP_ID INT,...

  • Using HTML and JavaScript. For this assignment you should submit a single zip file that contains...

    Using HTML and JavaScript. For this assignment you should submit a single zip file that contains the following two files: index.html script.js index.html should be a skeleton HTML page. So it should have the following tags: doctype html head meta title body script If you were to open index.html without including the associated JavaScript it should be entirely blank. You should then use JavaScript to create all of the content of this page and append it to the body of...

  • Project Description Complete the Film Database program described below. This program allows users to store a...

    Project Description Complete the Film Database program described below. This program allows users to store a list of their favorite films. To build this program, you will need to create two classes which are used in the program’s main function. The “Film” class will store information about a single movie or TV series. The “FilmCollection” class will store a set of films, and includes functions which allow the user to add films to the list and view its contents. IMPORTANT:...

  • PHP you need to create a form to allow the user to enter their name, email,...

    PHP you need to create a form to allow the user to enter their name, email, and address information. That information will be sent to a PHP script that will process and display that information. Your assignment should have two pages. The first page is straight html (user_input.html) that has a form with the appropriate form elements to collect the user input. The form should then be submitted using the POST method to a php script (display_user_info.php) that will process...

  • In this problem, you will create a selectable “To Do” List. To add a task to...

    In this problem, you will create a selectable “To Do” List. To add a task to this list, the user clicks the Add Task button and enters a description of the task. To delete a task from the list, the user selects the task and then clicks the Delete Task button. Open the HTML and JavaScript files provided as start-up files (index.html from within todo_list_Q.zip file). Then, review the HTML in this file. Note, within the div element, there is...

  • You need to implement a web application that is split in three parts, namely, Webpage, PHP and My...

    You need to implement a web application that is split in three parts, namely, Webpage, PHP and MySQL. Each of them will be used accordingly to solve a simple problem described below. Remember to implement the logic in the most secure way of your knowledge. PHP Implement a PHP function that reads in input a string from the user and store it in a table (e.g., in a field called "Content Name"). The function should be able to read the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT