0% found this document useful (1 vote)
116 views15 pages

TP Integration of Web Application

The document provides instructions for a series of technical programming (TP) exercises involving web application integration in PHP. TP1 involves displaying weather data from an array in checkboxes, submitting selected items with city/date, and displaying the results. TP2 creates an array of months/days and allows selecting a month to display its number of days. TP3 defines a Circle class to calculate surface area based on radius input. TP4 defines Student/Score classes to search and display student data. TP5 creates an Employee database to allow inserting, summing salaries by job, and searching by ID. TP6 instructions develop a basic to-do list application using the Laravel framework, allowing user registration/login and

Uploaded by

Touleen Akoum
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
116 views15 pages

TP Integration of Web Application

The document provides instructions for a series of technical programming (TP) exercises involving web application integration in PHP. TP1 involves displaying weather data from an array in checkboxes, submitting selected items with city/date, and displaying the results. TP2 creates an array of months/days and allows selecting a month to display its number of days. TP3 defines a Circle class to calculate surface area based on radius input. TP4 defines Student/Score classes to search and display student data. TP5 creates an Employee database to allow inserting, summing salaries by job, and searching by ID. TP6 instructions develop a basic to-do list application using the Laravel framework, allowing user registration/login and

Uploaded by

Touleen Akoum
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

‫الجامعة اللبنان ّية‬ Lebanese University

‫كلية التكنولوجيا‬ Faculty of Technology


Department : IAG

‫كلية التكنولوجيا‬

Tp Integration of Web Application

Prepared by: Mr Abdallh Wissam


Year: 2020 - 2021

1
TP-1-
A series of checkbox items are used to select weather values in Arrays. (Those values
are: rain, sunshine, clouds, hail, snow, TS.)
a) Write a php page “p01_cls.php” that displays all elements of the given array with
checkboxes values.

b) Write a php page “p01_fr.php” that is constituted from an


 array of the checked items,
 city, month and year
 Button: bulletin

c) When a user selects the weather phenomena and click the button bulletin

The php page “p01_trt.php” should displays the following result:

2
TP-2-
a) Create an array called $months in (“p02_cls.php”). Use the names of the
months as keys, and the number of days for each month as values. This
page should also contains two functions:

 display: takes the array ($months) as a parameter and populate its


elements in a dropdown list as shown in the following figure:

 getdays: should give the number of days related to particular


month.

b) Once again, you might be requesting the user to choose a particular month
the lists of months. Create a form “p02_frm.php” to a certain user through
which he can select a month.

c) Once he clicks on the button check it!, the page “p02_trt.php” displays the
following statement: "The month of January has 31 days.

3
TP-3-
a) Create a php page “p03_cls.php” that calculates the Surface Area of a Circle, this
page contains a class that is constituted of data and functions:

class MyCircle
{
// ----------------DATA-------------------------
 public $radius;

// ----------------Functions--------------------
 public function __construct
 public function setRadius ($radius)
 public function getRadius()
 public function getArea()
}

b) Create a form “p03_frm.php” for a certain user through which he can input a
radius value with a button “get surface” as shown in the following figure:

c) Once he clicks on the button “get surface”, the page “p03_trt.php” uses
class MyCircle in order to calculate the area of a given circle’s radius.
Moreover, this page should return the following result.

4
TP-4-
 The first page “p04_cls.php” contains the following class:

 The following arrays:

a) The second php page “p04_frm.php” should contain form with text box and
function JS: showID(student)

b) The second JS page “p04_trt.php” should search the id of a certain student


in order to display his id and his name and display his score as well.

5
c) TP-5-
Given the following emp table:

a) Create the database “…..” and the table “Emp” as well.


b) The transactions: Insert, Sum of salaries by job and Search by ID should
be developed in the php page “p05_cls.php” and contained the following
class:

c) Use the below interface p05_frm.php” through which a user can Insert,
calculate the Sum of salaries by job and Search by ID for an employee as
was given in the following figure:

d) The result of each function should be displayed in a php page called:


P05_trt.php

Tp-6- Users Tasks Web Site


6
Platform Laravel
Develop a simple Laravel Web App which will do below functions
 You can register and login to the web app
 You can add tasks to your to-do list
 You can edit as well as delete those tasks
 Your list is only visible to you thus it implements authentication using
email id and password
A. Part 1 download and install LARAVEL
1. From the chrome browser click the following URL:
Getcomposer.org

2. Click Download Button, you will be directed to the following page:

3. Run as administrator Composer-Setup.exe


4. Once you download successfully Compser-Setpup.exe you
can proceed to complete the installation steps

a. Do net check box at first window during set up about developer mode as shown
below:

7
b. In the setting window choose:

c. Click Browse and select php version shown below:

Click next…

B. Part 2 Create Offline Folder


1. C:\WINDOWS\system32> cd c:\
8
2. c:\> mkdir website
3. c:\> cd website
4. c:\website> composer global require laravel/installer
5. c:\ website > composer create-project laravel/laravel
6. c:\ website > cd laravel
7. c:\ website \laravel> composer require laravel/ui

C. Part 3 Develop web site laravel

9
10
Part 1: Create user Application
1. php artisan serve
http://127.0.0.1:8000

2. http://127.0.0.1:8000/login
Error: Pages are not registered in the web.php file

3. php artisan ui:auth


Auth::routes(); Route::get('/home', 'HomeController@index')->name('home'); added web.php
HomeController.php : is automatically created in C:\p1_wissam\wesite_wissam\app\Http\Controllers
Home.blade: is automatically created in C:\p1_wissam\wesite_wissam\resources\views

4. http://127.0.0.1:8000/login
login page is well displayed

5. Connect to the database and register a user: user123


http://127.0.0.1:8000/login : Error: datable configuration not well done

6. .env: Modify the first line to “sqlite” and delete the others
C:\p1_wissam_init\website_wissam\

7. database.sqlite : DB is not created yet, you should create it


notpad++--->newfile-->saveAs-->database.sqlite (C:\p1_wissam\wesite_wissam\database)

8. Create physically the table user and check it in the databse.sqlite:


php artisan migrate
First Result: gives an error that you should modify .env file related to the database configuration as shown in the
following figure:

After configure the “.env” file re type the above command and you should get the following result
in C:\Prof\p1_wissam\website_wissam\database\migrations
Migration table created successfully.
Migrating: 2014_10_12_000000_create_users_table
Migrated: 2014_10_12_000000_create_users_table (0.02 seconds)

9. Reconnect to the database and register a user: user123


http://127.0.0.1:8000/register, Result: User123: well added

11
Part 2: Create Tasks Application

1. php artisan make:migration create_tasks_table --create=tasks


C:\p1_wissam\wesite_wissam\database\migrations\ 2019_10_18_143111_create_tasks_table.php

2. Add more columns to the 2019_10_18_143111_create_tasks_table.php


$table->string('description');
$table->unsignedBigInteger('user_id');
$table->index('user_id');
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');

3. Create the table physically: php artisan migrate


Migrate table successfully migrated

4. Check the database file “database.sqlite” after migration


C:\p1_wissam\wesite_wissam\database

5. Open the database.sqlite file using DBbrowserForSQlite, insert manually


insert into tasks (id, description, user_id) values ('1' , 'forecaster' , '1' ) ;
insert into tasks (id, description, user_id) values ('2' , 'observer' , '1' ) ;
commit ;

6. create the model Tasks: php artisan make:model tasks


check Tasks .php file in C:\p1_wissam_V3\wesite_wissam\app\

7. Modify the two mentioned Models (User&Tasks) so as : User has many Tasks:
User.php: public function manytasks() {
return $this->hasMany(tasks::class);
}
Tasks.php  : public function oneUser(){
return $this->belongsTo(User::class);
}

8. create the associate Controller for Tasks ”taskscontroller”:


php artisan make:controller taskscontroller
TasksController.php : is created in C:\p1_wissam\wesite_wissam\app\Http\Controllers

9. LoginController.php and RegisterController.php
On around Line 28, you will find code
“protected $redirectTo = ‘/home’; Change it to  “protected $redirectTo = ‘/’;”

Note: in the next section of the tutorial each views that have been programmed, in order to
test it, you should start form the login / logout views.

12
Part 3: Programing

5_Display.blade.php: Display all Tasks for a certain user


Web.php:

TasksController.php

5_Display.blade

13
6_Add.blade.php: Add Tasks for a certain user
Web.php:

TasksController.php

6_Add.blade

Web.php:

TasksController.php

14
7_Update.blade.php: Modify Tasks for a certain user
Note in : 5_Display.blade

Web.php:

TasksController.php

7_Update.blade.php

Web.php:

TasksController.php

8_Delete.blade.php: Modify Tasks for a certain user

15

You might also like