Activity 10
Activity 10
We will develop a simple insert function using PHP in a PDO way. Follow the steps provided. Make sure that you have
already installed XAMPP in your computer. Once installed, run Apache and MySQL services.
4. Enter the attributes/fields for the student table. Make sure that the unique ID (student_id) is being marked by a
primary key by simply clicking the blank column besides Not null column.
The Auto increment box is also checked. This is applicable only to the unique key.
5. Save the table named “student”.
6. Here is now the list of table/s under the Enrollment database.
10. Open the gadtc-enrollment folder and make 3 folders. These are:
config folder
functions folder
objects folder
11. Open sublime or any editor.
12. From the file menu, click the Open Folder and select the gadtc-enrollment file from the htdocs.
13. Copy the following and save it as “connection.php” the config folder.
14. Open new file and copy below. Save it as “student.php”. The object folder serves as your table from the
database. Under this file, we are creating a class named Student that contains attributes and methods.
15. Open again another file and name it as “add_student.php”. Save the file under the gadtc-enrollment folder.
Copy the code below.
16. Create an action script name it as “action_add.php”. Save the file under the gadtc-enrollment folder. Make sure
that the functions or files that have been called must be included by using the code “include_once”. Copy the
code below.
17. Create a new file named “savefunction.php” and saved it in the functions folder. This file saves as the controller.
You can add more functions inside this file. Copy the code below.
18. Go back to the student file under the objects folder. Add this code below:
19. Open any browser and type this URL to the address bar to run the program:
localhost/gadtc-enrollment/add_student.php
20. Open the student table and check if it is saved.
Output submission:
1. Write your name, your Course and Year at the header of the document.
2. Your code to every php file.
3. Screenshot of the database creation from the DBMS program (ex: SQLYog, Navicat, phpMyAdmin, etc.)
4. Screenshots of the of the output during run time.
5. Picture of you working in a computer with a timestamp.
Note: No copying of work. You can add another field in the program like: year, gender, birthday etc.