Tutorial Membuat Toko Online PHP MySQLI - 6 Tambah Produk

Team TRAINIT
28 Dec 201610:36

Summary

TLDRThis tutorial walks viewers through the process of adding products to an online store. It covers steps such as creating a database, building an 'Add Product' page with a form for inputting product details (name, price, weight, description, and photo), and uploading product images. PHP is used to handle form submissions, save data to the database, and display the uploaded image on the product page. The tutorial also includes guidance on setting up image folders and testing the functionality. Viewers are encouraged to apply the same method to other store functions, like adding customers.

Takeaways

  • 😀 The tutorial demonstrates how to add products to an online store using PHP.
  • 😀 The first step is to create a link for adding products in the 'produk.php' file below the product table.
  • 😀 After creating the link, the tutorial shows how to set up a new page for adding products (index.php).
  • 😀 A new file, 'tambah_produk.php', is created, with an H2 title for adding products.
  • 😀 A simple form is created to input product details like name, price, weight, description, and photo.
  • 😀 Input fields for name, price, weight, description, and photo are provided, with validations such as specifying the unit for weight.
  • 😀 A 'Save' button is created to submit the product data to the server.
  • 😀 A 'foto_produk' folder is created to store uploaded product images, and specific file permissions are set for Linux users.
  • 😀 The tutorial demonstrates how to handle file uploads and store the uploaded product images in the 'foto_produk' folder.
  • 😀 PHP code is used to save the product data into a database, including the product name, price, weight, photo, and description.
  • 😀 After saving the product, a success message is displayed, and the page is refreshed to show the new product in the list with its image.

Q & A

  • What is the main focus of this tutorial video?

    -The tutorial focuses on teaching how to add a product to an online store using PHP and MySQL, including setting up a form to input product data and saving it into the database.

  • What is the first step in preparing for adding a product?

    -The first step is to prepare the database by ensuring it is set up properly in localhost/phpmyadmin, and then opening the relevant database (in this case, the 'toko' database).

  • How does the tutorial suggest creating a link to add a product?

    -The tutorial recommends adding a link in the **produk.php** file below the product table, which will direct users to a page for adding a product. The link is given a class 'Tambah Data' for styling.

  • What should be included in the 'tambah_produk.php' file?

    -The **tambah_produk.php** file should include a form to input product data, such as name, price, weight, description, and a file upload option for the product's photo.

  • Why is the 'foto_produk' folder important in this tutorial?

    -The 'foto_produk' folder is used to store the uploaded product photos. It is necessary to set the correct permissions on this folder, especially for Linux users, so that files can be uploaded successfully.

  • What PHP functionality is used to handle the uploaded product photo?

    -The PHP functionality used to handle the uploaded product photo involves the **$_FILES** superglobal, which captures the file information, and the **move_uploaded_file()** function to store the photo in the correct folder.

  • What database query is used to save the product information?

    -An **INSERT INTO** query is used to insert the product data, including the name, price, weight, photo filename, and description, into the 'produk' table in the database.

  • How is the success of data insertion communicated in the tutorial?

    -The tutorial displays a success message on the webpage, saying 'Data produk berhasil disimpan!' (Product data successfully saved), and then refreshes the product page to show the newly added product.

  • How is the product photo displayed on the product page?

    -The product photo is displayed by referencing the 'foto_produk' folder and using an HTML **<img>** tag with the photo's filename, ensuring it is displayed with a width of 100 pixels.

  • What should be checked if the uploaded product photo does not appear on the product page?

    -If the product photo does not appear, it could be due to incorrect file permissions on the upload folder, or the product's data may not have been inserted properly into the database. Double-check the upload path and database insertion.

Outlines

plate

このセクションは有料ユーザー限定です。 アクセスするには、アップグレードをお願いします。

今すぐアップグレード

Mindmap

plate

このセクションは有料ユーザー限定です。 アクセスするには、アップグレードをお願いします。

今すぐアップグレード

Keywords

plate

このセクションは有料ユーザー限定です。 アクセスするには、アップグレードをお願いします。

今すぐアップグレード

Highlights

plate

このセクションは有料ユーザー限定です。 アクセスするには、アップグレードをお願いします。

今すぐアップグレード

Transcripts

plate

このセクションは有料ユーザー限定です。 アクセスするには、アップグレードをお願いします。

今すぐアップグレード
Rate This

5.0 / 5 (0 votes)

関連タグ
Online StorePHP TutorialE-commerceProduct ManagementWeb DevelopmentAdd ProductsDatabaseAdmin PanelPHP CodingWeb DesignTutorial
英語で要約が必要ですか?