WEB Development Course
WEB Development Course
Dr Benabderrezak
Researcher in Cyber Security
Full-stack Web developer 1
Work Plan
1. WEB basics
2. HTML
3. CSS
4. Javascript
5. Jquery
6. UML
7. Database (Mysql)
8. PHP
2
1. WEB basics
● Internet
● World Wide Web (W3)
● Client-server architecture
● Web browser (client) / Web server
● Static vs Dynamic Website
● Front-end vs Backend
● Library, Framework, Plug-in, Add-ons
● HTTP protocol
● URL, URI, URN
● Code editor 3
Internet
- Internet, also known as "network of networks"
4
World Wide Web (WWW , W3)
- Refers to all public websites or pages that users can access on their
5
Client-Server Architecture
- A design model used for communication between computers, software or
services.
6
Browser
⇒ Represents an essential software that facilitates your Internet exploration.
1. Visit websites
2. Search online
3. Read emails
4. Watch videos
5. Make purchases on the Internet
6. …etc.
7
Web Server
A web server is a computer or software that stores and transmits web
8
The most used Web servers
9
Static website
A static website is a website whose content is previously created and does
10
Static website
11
Dynamic Website
A dynamic website is a website whose content is generated in real time
12
Frontend, Backend
1. Frontend : the visible and interactive part of an application
processes.
13
14
Library vs Framework
15
Plug-in
A plug-in is a small piece of software that adds specific functionality to
an existing application.
16
Add-ons
Add-ons is a general term used to describe modules, extensions or
software or system.
17
Protocol
A protocol is a set of rules for a specific mission
18
Or : A protocol is a set of rules that define how two entities (objects) can
.اﻟﺒﺮوﺗﻮﻛﻮل ھﻮ ﻣﺠﻤﻮﻋﺔ ﻣﻦ اﻟﻘﻮاﻋﺪ اﻟﺘﻲ ﺗﺤﺪد ﻛﯿﻒ ﯾﻤﻜﻦ ﻟﻜﺎﺋﻨﯿﻦ اﻟﺘﻮاﺻﻞ ﻋﻠﻰ اﻟﺸﺒﻜﺔ
19
19
HTTP protocol (HyperText Transfer Protocol)
20
HTTP protocol (HyperText Transfer Protocol)
21
HTTP communication process
22
HTTP communication process
23
24
25
HTTP Query
26
HTTP Response
27
URL, URI, URN
28
URI structure
29
Understanding the Web and HTTP
[Link]
30
Code editor
- Software that allows developers to create, modify and organize codes
31
32
Mr Benabderrezak
Researcher in Cyber Security
Full-stack Web developer 33
HTML
● HTML is the standard markup language for creating web pages
34
Basic structure
35
Basic structure
● <!DOCTYPE html> : defines this document as an HTML5 document
● <head> : contains meta information about the HTML page (SEO part)
● <body> : defines the body of the document (which sees the user)
36
Html Elements
- The HTML element is everything from the start tag to the end tag:
37
Html Elements
38
Heading
39
Paragraphs
40
Lists
1. Unordered list
41
Lists
2. Ordered list
42
Lists
3. Description List
43
Links
Images
44
Tables
45
Les tables
46
HTML attributes
- All HTML elements can have attributes
47
Classes
● The HTML class attribute is used to specify a class for an HTML
element.
48
IDs
● The HTML id attribute is used to specify a unique identifier for an HTML
element
● You cannot have more than one element with the same identifier in an
HTML document
49
Forms
50
Forms
51
Form elements
The HTML <form> element may contain one or more of the following
form elements:
● input : to insert data with specific type (text , email , number …)
● label : to add explanation to input element
● select : select option from list
● textarea : input multi row
● button
● ….etc
52
Form elements - Input types
53
input attributes
1. value : an initial value for an input field
field.
54
input attributes
6. min and max : the minimum and maximum values of an input field.
55
input attributes
9. placeholder : a short index that describes the expected value of an
input field.
12. height and width : specify the height and width of a <input
type="image">
56
Form elements - Button
57
SEO (Search Engine Optimization)
- The purpose of any website is to generate traffic
- And many of these visitors come from search engines.
- The best ways to engage an audience is to use HTML tags for SEO.
58
HTML tags pour SEO
⇒ SEO is the process of improving your website to increase its visibility
in search engines (google, bing, etc.)
59
HTML Semantic vs Non-semantic elements
60
61
HTML tags pour SEO
[Link]
62
HTML Emmet
⇒ It is a way to write html code quickly
63
HTML Emmet
[Link]
64
CSS
Dr Benabderrezak
Researcher in Cyber Security
Full-stack Web developer 66
CSS
CSS describes how HTML elements should be displayed on the screen
67
CSS integration in HTML
68
CSS integration in HTML
69
CSS Syntax
70
CSS Box model
71
Common CSS properties
72
73
74
Common CSS properties
[Link]
75
CSS selectors
76
77
CSS Responsive Design
● Responsive web design makes your web page look good on all devices.
78
CSS responsive design - Viewport
- A Browser’s viewport is the area of the web page in which the content
- The viewport varies with the variation in screen size of the devices on
smartphone or tablet.
79
CSS responsive design - Viewport Syntax
- initial-scale=1.0 : sets the initial zoom level when the page is first
81
CSS responsive design - Grid view
Many web pages are based on a grid-view, which means that the page is
82
CSS responsive design - Grid view
83
CSS responsive design - Grid view
100% , and will shrink and expand as you resize the browser window.
84
CSS responsive design - Grid view
[Link]
85
CSS responsive design - Media queries
86
CSS responsive design - Media queries Example
lightblue :
87
CSS responsive design - Media queries Example
88
CSS responsive design - Media queries Example
89
CSS responsive design - Media queries
Read more about media queries :
[Link]
90
CSS responsive design - Images
If the width property is set to a percentage and the height property is set
91
CSS responsive design - Video
If the width property is set to a percentage and the height property is set
92
93
JavaScript
Dr Benabderrezak
Researcher in Cyber Security
Full-stack Web developer 94
95
Usefulness of Javascript ﻓﺎﺋﺪة
● Create interactive elements : such as forms, drop-down menus, buttons and
animations.
Keys… e
answers. 96
JS integration
There are following 3 main ways to add JavaScript to your web pages:
1. Embedding code
2. Inline code
3. External file
97
JS integration
<script>...</script> tag
98
JS integration - Embedded
99
JS integration - Embedded
After clicking
on the button
100
JS integration - Inline
2. Inline code : Placing JS code directly inside HTML tags
101
JS integration - External file
3. External file : Making a separate JavaScript file having .js as an extension.
102
Output
103
Output
104
Output
[Link]
105
Keywords
106
Functions
108
Objects
109
Objects
110
HTML Events
does.
4. ….etc.
111
Common HTML Events
Html Events
[Link]
114
Loops
JavaScript supports different types of loops:
115
Loops
1. for - loop through a block of code a number of times
is true
116
Loops
for - loop through a block of code a number of times
118
For loop
119
Loops
120
For in loop
121
Loops
for/of - loops the values of an iterable object
122
For of loop
123
Loops
124
While loop
125
Loops
do/while - loop also through a block of code when a specified condition is true
126
Do while Loops
127
Break/continue
128
HTML DOM Elements
129
HTML DOM Elements
130
HTML DOM Elements
- Often, with JavaScript, you want to manipulate HTML elements.
- To do that, we must first find the elements. There are several ways of doing
it:
1. Find HTML elements by id
2. Find HTML elements by tag name
3. Find HTML elements by class name
4. Search for HTML elements by CSS selectors
5. Search for HTML elements by HTML object collections
131
HTML DOM Elements
132
HTML DOM Elements
133
API
API in simple words : a website without frontend
134
API call in Javascript
4 Ways to Make an API Call in JavaScript:
135
API call in Javascript - fetch() method
136
API call in Javascript
See all methods with examples :
[Link]
137
Jquery
Dr Benabderrezak
Researcher in Cyber Security
Full-stack Web developer 139
Jquery ?
- jQuery is a lightweight JavaScript library, "write less, do more".
like AJAX calls (calls BDD in real time) and DOM manipulation.
140
⇒ The jQuery library contains the following features:
● HTML/DOM manipulation
● CSS manipulation
● AJAX
141
Syntax
142
Examples
$(document).ready(function(){
});
143
Jquery Selectors
144
Jquery Selectors
145
Jquery Events
146
147
- See more examples of Jquery events :
[Link]
148
Json
- JSON is one of the data exchange formats
149
150
Jquery Ajax
⇒ Load data in the background and display it on the web page, without
151
Jquery Ajax
152
jQuery call api
$(document).ready(function() {
$.ajax({
url: '[Link]
method: 'GET',
dataType: 'json',
success: function(data) {
[Link]('API response:', data);
},
error: function(error) {
[Link]('Error:', error);
}
});
});
153
154
UML
Dr Benabderrezak
Researcher in Cyber Security
Full-stack Web developer 155
1. UML ?
156
156
1. why UML ?
system.
functionality
157
157
2. UML diagrams
158
158
2. UML diagrams
1. Static View
2. Functional View
Represents the functionality of the system and how users interact with it
159
159
2. UML diagrams
3. Dynamic View
Describes how the system behaves over time, detailing the flow of control
160
160
Class diagram
- Used to represent the static structure of a software system.
- It represents the system plane ( classes, attributes, methods and relationships
between classes)
161
Class diagram
162
Class diagram
163
Normalizing the Class Diagram
1NF : All data must be atomic ( a single value and not a list of values ) and constant over
time
164
- 2NF: (on association classes)
1. In addition to respecting the rules of 1NF
2. a table must not contain partial dependencies. A partial dependency exists
when a non-primary key column depends only on part of a composite primary
key.
165
3NF:
166
Use case Diagram
It shows the interactions between the actors and the system, describing the
features offered by the system.
167
Sequences diagram
168
169
Database - Mysql
Dr Benabderrezak
Researcher in Cyber Security
Full-stack Web developer 171
Database concept - ﻗﺎﻋﺪة اﻟﺒﯿﺎﻧﺎت
The database is simply a huge file used to store information in an
organized way
ﻗﺎﻋﺪة اﻟﺒﯿﺎﻧﺎت ھﻲ ﺑﺒﺴﺎطﺔ ﻣﻠﻒ ﺿﺨﻢ ﯾﺴﺘﺨﺪم ﻟﺘﺨﺰﯾﻦ اﻟﻤﻌﻠﻮﻣﺎت ﺑﻄﺮﯾﻘﺔ ﻣﻨﻈﻤﺔ
172
The importance of databases
- Easily accessible and managed data ()ﯾﺴﮭﻞ اﻟﻮﺻﻮل إﻟﻰ اﻟﺒﯿﺎﻧﺎت وإدارﺗﮭﺎ
- ……etc.
173
The tables of a database
174
The tables of a database
1. The name
175
The tables of a database
176
Key types
177
Key types
1. Primary Key
178
2. Foreign Key
- A field (or collection of fields) in one table that uniquely identifies a row of
another table.
- Establishes a relationship between two tables.
- Enforces referential integrity.
179
3. Composite Key
- A primary key composed of two or more columns to uniquely identify a row.
180
4. Candidate Key
- A column or set of columns that could be used as a primary key.
181
5. Alternate Key
- A candidate key that is not chosen as the primary key.
182
6. Super Key
- A set of one or more columns that can uniquely identify a row in a table.
- Includes the primary key and candidate keys, as well as any additional
attributes.
183
7. Unique Key
- Ensures all values in a column or set of columns are unique.
- Similar to primary keys but can accept one NULL value (in some databases).
184
What is a relational database ?
to organize information
185
What is a relational database ?
186
Relational vs Non-relational database?
187
Types of data in SQL
Data type Description Example
189
SQL
- SQL is the standard language for processing relational databases.
190
The most important SQL commands
191
The most important SQL commands
192
The most important SQL commands
194
DBMS
A database management system (DBMS) is a system software that
allows users and programmers to create and manage databases.
195
- Well-known DBMS: Oracle, SQl server, Mysql, Postgresql,
Mariadb, mongoDB
196
Install MySQL in Ubuntu
[Link]
Install Postgres in Ubuntu
[Link]
tall-and-configure-postgresql-on-ubuntu-20-04-4fd3cf072d6f
Database Administration Tool
These tools provide a graphical / Web interface to automate related
tasks with databases
ﺗﻮﻓﺮ ھﺬه اﻷدوات واﺟﮭﺔ رﺳﻮﻣﯿﺔ ﻟﻠﻘﯿﺎم ﺑﺎﻟﻤﮭﺎم ذات اﻟﺼﻠﺔ ﺑﻘﻮاﻋﺪ اﻟﺒﯿﺎﻧﺎت
199
Exercise
1. Create a database called "ManageEmployees".
2. In this database, create a "Employees" table with the following
columns
● ID (integer, primary key, auto-incremented)
● Name (string of characters)
● Age (number)
● post (string)
200
Exercise (following)
1. Insert 3 dummy employees in the "Employees" table.
201
Aggregate Functions
An aggregate function is a function that performs a calculation on a set of
202
Aggregate Functions - Example
203
Aggregate Functions
204
Transactions
A transaction in a database is a sequence of operations performed as a
اﻟﻤﻌﺎﻣﻠﺔ ﻓﻲ ﻗﺎﻋﺪة اﻟﺒﯿﺎﻧﺎت ھﻲ ﺳﻠﺴﻠﺔ ﻣﻦ اﻟﻌﻤﻠﯿﺎت اﻟﺘﻲ ﯾﺘﻢ إﺟﺮاؤھﺎ ﻛﻮﺣﺪة ﻋﻤﻞ واﺣﺪة
ﯾﺠﺐ اﺳﺘﺨﺪام اﻟﻤﻌﺎﻣﻼت ﻋﻨﺪﻣﺎ ﯾﻜﻮن ھﻨﺎك اﺣﺘﻤﺎل أن ﯾﺆدي ﻋﺪم إﻛﻤﺎل أو ﻗﺮاءة أو ﻛﺘﺎﺑﺔ ﺷﺨﺺ
207
Transactions
208
ACID properties
[Link]
Functions
A Database Function is a routine that accepts parameters, performs an
action (such as a complex calculation) and returns the result of that action
as a value
Functions keywords
1. Parameters: Functions can accept input parameters, which allow you to pass
3. Return Value : The function returns a single value as the result of its
processing. This value can be of any data type supported by the database.
Functions syntax
Functions - Example
Triggers
- A trigger is a database object that is associated with a table.
table: INSERT, UPDATE and DELETE and it can be invoked before or after the
event.
Triggers Syntax
Triggers Syntax
Keyword Uses
Create trigger This keyword begins the syntax for creating a new trigger in
MySQL
BEFORE | AFTER These keywords specify when the trigger should execute
INSERT | UPDATE | specify the database operation that causes the trigger to fire
DELETE
ON table_name specifies the table on which the trigger is defined
FOR EACH ROW specifies that the trigger should execute once for each row in
the table
Triggers Syntax
Keyword Uses
BEGIN ... END Used to enclose the body of the trigger
NEW Refers to the new values that will be inserted or updated into the
table
OLD Refers to the old values that will be inserted or updated into the table
SET used to assign values to variables or to update column values in the
`NEW` statement
Triggers Syntax
Keyword Uses
IF ... THEN ... END IF used for conditional logic within trigger bodies,
on conditions
INSERT INTO used to insert rows into a table, often used within
Mr Benabderrezak
Researcher in Cyber Security
Full-stack Web developer 224
PHP ?
● PHP is a server scripting language, and a powerful tool for creating dynamic
225
How does PHP work?
226
Syntax
227
Variables
● A variable starts with $ followed by the variable name
- Ex: $variable_name
underscore character ( _ )
228
Variables
● A variable name can only contain alphanumeric characters and underscores
● Variable names are case sensitive ($age and $AGE are two different
variables
229
Variables
230
Data types
String $name = ”ahmed”;
$array_2= [‘a’,’b’,c’];
NULL $x = null;
231
Constants
- A constant is an identifier (name) for a single value.
232
Constants
233
Constants
- Syntaxe : define(nom, valeur)
234
Magic constants
PHP has 9 predefined constants that change values depending on
where they are used, and so they are called "magic constants".
235
Les constants magiques
236
Operators
1. Arithmetic: +, - , *, / , % , **
3. Comparison: == , ==, != , <>, !=, <, <= , > , >=, < = >
238
Conditions
1. if (condition) { // code}
2. if (condition { // code} else { // another code}
3. if (condition 1 ) { ……} elseif (condition 2 ) { ….} else { ….}
4. switch ($var) {
case 1 : instructions; break;
case 2 : instructions ; break;
…..
default : code to execute if n is different from all labels ;
}
239
Loop
1. while (condition) { // code}
240
Functions
⇒ syntax : function function_Name() { // code to be executed; }
241
PHP forms
⇒ PHP $_GET and $_POST superglobals are used to collect form
data.
[Link]
[Link]
242
Arrays
- An array is a special variable that can hold many values under a single name
243
1- Indexed array
244
1- Indexed array
245
1- Indexed array
246
1- Indexed array
247
1- Indexed array
248
1- Indexed array
249
2- Associative array
250
2- Associative array
251
2- Associative array
252
253
254
3- Multidimensional Arrays
255
3- Multidimensional Arrays
256
3- Multidimensional Arrays
257
3- Multidimensional Arrays
258
3- Multidimensional Arrays (display elements using loops)
259
Array functions
260
Array functions
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
PHP with MySQL
277
PHP with MySQL
278
279
280
281
282
283
284
PHP sessions
- A session is a way to store information (in variables) to be used across
multiple pages.
285
PHP sessions
- To use php session , you must start it :
286
PHP sessions
- To use php session attributes:
287
PHP sessions
- To close or destroy php session
288
References
289
PHP OOP
Object-oriented programming (OOP) is a computer programming model
that organizes software design around data, or objects, rather than functions
and logic
290
PHP OOP concepts
Before we dive into PHP specifics, let's grasp the core concepts of OOP:
● Classes / Objects
● Inheritance
● Polymorphism
● Encapsulation
● Abstraction
291
PHP OOP concepts
● Classes : Blueprints for creating objects, defining their structure and actions
292
PHP OOP concepts
● Inheritance : Creating new classes based on existing ones, inheriting
293
PHP OOP concepts
● Polymorphism : the ability of any data to be processed in more than
one form
294
PHP OOP concepts
● Encapsulation : Bundling data (properties) and methods that operate
295
PHP OOP concepts
● Abstraction : Focusing on essential features while hiding
implementation details
296
PHP OOP concepts
● Constructor : A special type of function called to create an object
297
PHP OOP - Example
298
MVC
Model–view–controller (MVC) is a software design pattern commonly used
for developing user interfaces that divides the related program logic into
299
MVC
300
MVC - user request handling
301
302
Laravel ?
model.
303
Why Laravel ?
304
Laravel Project Structure
305
Laravel Project Structure
● app : Contains the source code of the application (templates, controllers, etc.).
● public : Contains the [Link] input file and the public resources.
306
Laravel Project Structure
● resources : Contains raw views, language files and assets.
307
Laravel Routes
- Routes define the application entry points
308
Laravel Controllers
- Controllers contain the logic for processing HTTP requests.
309
Laravel Controllers
- To create a controller : php artisan make:controller UserController
310
Laravel View
- The views are Blade files located in the resources/views directory.
311
Laravel Model
- A class interact with the database, and is associated with a database table
312
PHP & Laravel development environment
If you are using windows; the best environment for PHP & laravel development is
Laragon
[Link]
313
Laravel CRUD Application
To build a simple crud in laravel , follow these steps :
[Link]
xample-tutorial-42f0c2d3b13d
314