Professional Documents
Culture Documents
Module 4 PHP and Mysql PDF
Module 4 PHP and Mysql PDF
3 Days:
1.
PHP Introduction
PHP Syntax
PHP Variables
PHP String
PHP Operators
PHP If...Else
PHP Switch
PHP Arrays
PHP While Loops
PHP For Loops
PHP Functions
PHP Forms
PHP $_GET
PHP $_POST
2 Days
3. PHP Database
MySQL Introduction
MySQL Connect
MySQL Create
MySQL Insert
MySQL Select
MySQL Where
MySQL Order By
MySQL Update
MySQL Delete
PHP ODBC
3 Days
2. PHP Advanced
PHP Date
PHP Include
PHP File
PHP File Upload
PHP Cookies
PHP Sessions
PHP E-mail
PHP Secure E-mail
PHP Error
PHP Exception
PHP Filter
p
p
p
p
0
p p
p p
p p !
p p"#$%
p p"#p%
0
p p
p p
0
p p
'
p p()
p p
p p*!
p p *!
p p
p p
p p
0
+
+,
+'
+&
p p&,(
0
|
"#
$ PHP Introduction
$ PHP Syntax
$ PHP Variables
$ PHP String
$ %&#
&&
&'(&
)
Introduction
What is PHP?
,
What is MySQL?
&
&&&
PHP + MySQL
p p& +&'
12*&)
,
Why PHP?
p
p
p
p
Where to Start?
|
Comments in PHP
,p p;;&
+&&;<<;&
&&
/
6&8
68
67
;;&&
;<
&&
<;
78
6;8
6;&8
||
Variables in PHP
*&
/
1
/
%p p=&/
p p#
=>&?:
@p p&&=
/,
/
A
&#
67
=*?0 1B0:
=*?":
78
|
|
67
=*"?0 1B0:
=*
?01B0:
=*"/00/=*
:
78
#
1B1B
,
&/
')/
#
$ PHP Operators
$ PHP If...Else
$ PHP Switch
* PHP Arrays
$ PHP While Loops
$ <
|
Description
Example
Result
%
*?
*Y
*?
+*
<
*?
*<
";
;
/
'
&)
D
"CD!
"CD
"
YY
,&
*?
*YY
*?
++
&
*?
*++
*?
|
Comparison Operators
Operator
Description
Example
??
E
??!
B?
E
B?!
68
E
68!
8!
6!
8?
8?!
6?
6?!
Logical Operators
Operator
Description
Example
*?
?('*6"C8")
FF
*?
?('*??FF??)
*?
?(B'*??)
Logical Operators
Operator
Description
Example
*?
?('*6"C8")
FF
*?
?('*??FF??)
*?
?(B'*??)
|
&
The if Statement
Example
I
Example
6&8
68
67
'=*)
H
"#
0@&"0:
:
#
0@&
0:
:
(#
0@&(0:
:
#
0@&"(0:
I
78
6;8
6;&8
PHP Arrays
Example
1
PHP Loops
-&
/
,p p&#
while +
do...while +
for +
&
&
foreach +
&
*
The while Loop
*
/
Syntax
'@ )
H
@ @ :
I
|
Example
5*&
(#
PHP For
*Loops
PHP
*Functions
PHP Forms
PHP $_GET
PHP $_POST
%&#&&
&
&
#&
'&
)
p&#
#
@ #5
/,425
/,3% 5
/
@#&
Example
*&?"/
E/"&#
6&8
68
67
'=?":=6?:=YY)
H
0&0/=/06;80:
I
78
6;8
6;&8
Example
&
&/%&
9
/
p&
&
Example
6;8
6;&8-#
"Y"?"
p p=>.5=>p-
&&
&
/
PHP Form Handling
&&
&p p
&&
automatically p p
/
Example
6;8
6;&8
1&
&
&p p0&/0#
6&8
68
1&67=>p-J0&0K:
78B6;8
G67=>p-J00K:78
/
6;8
6;&8
Example
5*
0&/0=>.5
&'&&
&
=>.5)#
1&67=>.5J0&0K:78/6;8
G67=>.5J00K:78B
HP $_POST Function
Example
|
5*
0&/0=>p-
&'&&
&
=>p-
)#
1&67=>p-J0&0K:78B6;8
G67=>p-J00K:78/
p p+=>4525
=>.5=>p-
=>
--N,5/
=>4525
&.5
p-&/
Example
1&
67=>4525J0&0K:78B
6;8
G67=>4525J00K:78
/
#
$ PHP Date
$ PHP Include
$ PHP File
%&#
'(&
)
E
&')
&;&/
&#
+ 4&'C"(")
&+ 4&'C""
)
G+ 4')
67
'0G;&;0)/06;80:
'0G/&/0)/06;80:
'0G+&+0)
78
Opening a File
i
i
i
i i
i i
i i
i i
i
i i
ii i
i i i !"
# iii
i
i i i !"
# iii
i
3')
ote: ,')
C')/
Example
*&&
')#
6&8
68
67
=?'0&/*000)*'02
B0):
78
6;8
6;&8
Closing a File
Check End-of-file
')
/
ote: G&
*&B
''=))050:
|
Example
#
$ PHP File Upload
$ PHP Cookies
*PHP Sessions
$ PHP E-mail
<
p
+$
$$
'#& # $ ' $
( &# ( $,
($ ,
($ , ($ ' $
- %& )&
'#&(' *
-. ( &#
0 , 1
0%$ 1
3 ,& $ 23 $#3
0($ , $-23' $ 4( &*
5($ , 6 31
&- &23,'
0 %& ($ 23( &317 &- ,& 05 %& 1
0- ' &23( &3 - ,&23( &3 23( &3 51
0% 51
0- ' &23#'%,3 - ,&23#'%,3 ) '&23 '%,3 51
05($ ,1
05%$ 1
05 , 1
2
Restrictions on Upload
PHP Sessions
|
*&
,*&&+
/')
00
/,00
&/,00A*
00"#
67
>'):
Destroying a Session
#
PHP Secure E-mail
PHP Error
PHP Exception
PHP Filter
*
&&&
,@p4@%
5
5*&
67
;;*
@&'=&)
H
'=&8")
H
5*'0&"0):
I
:
I
;;*
@&'
):
78
HP Filter
*&
67
=?"
(:
'B>'=3, 54>% ,%5>,@))
H
'0,0):
I
H
'0,0):
I
78
,*&>')0&>00&*>0#
67
=?(CC:
=>?'
00?8
'
0&>0?8C
0&*>0?8
)
):
'B>'=3, 54>% ,%5>,@=>))
H
'0,0):
I
H
'0,0):
I
78
#
MySQL Introduction
MySQL Connect
MySQL Create
* MySQL Insert
MySQL Select
%&# &&
&
<
0
!
%"
"
(
"
#$
"
&'
%
&$
%
%
%"
Queries
*&
,*&
'=)/00
*#
67
=?&E>'00000"
(0):
'B=)
H
'A
#A/&E>')):
I
;;&
78
Closing a Connection
&
/
&E>')#
67
=?&E>'00000"
(0):
'B=)
H
'A
#A/&E>')):
I
;;&
&E>'=):
78
PHP MySQL Create Database and
Tables
%&/
Create a Database
45%5%% %5&
/
Syntax
45%5%% %5>&
Example
67
=?&E>'00000"
(0):
'B=)
H
'A
#A/&E>')):
I
'&E>E'0
45%5%% %5&>0=))
H
00:
I
H
05#0/&E>'):
I
&E>'=):
78
,
*
,@54,@->&
% 25'"
(///)
&&
&#
,@54,@->&'&"
&
&(///)
% 25'"
(///)
%&
|
&#
6&8
68
||
|
Example
*&0p0'<
)#
67
=?&E>'00000"
(0):
'B=)
H
'A
#A/&E>')):
I
&E>>'0&>0=):
=?&E>E'05 5
<34-p0):
'=?&E>>'=))
H
=JA3@&AK/00/=JA @&AK:
06;80:
I
&E>'=):
78
|
*&&*& #
67
=?&E>'00000"
(0):
'B=)
H
'A
#A/&E>')):
I
&E>>'0&>0=):
=?&E>E'05 5
<34-p0):
"6?A"A8
8
683&6;8
68 &6;8
6;80:
'=?&E>>'=))
H
0680:
0680/=JA3@&AK/06;80:
0680/=JA @&AK/06;80:
06;80:
I
06;80:
&E>'=):
78
|
!#
MySQL Where
MySQL Order By
*MySQL Update
MySQL Delete
PHP ODBC
%&#
&
&'"C&
)
|
1
Example
|
*&
|
5 55&
/
Delete Data In a Database
5 5534-&
&/
Syntax
5 5534->&
1 545&>&?&>
||
5*&
|||
-
%p&&
,'%p,)
Create an ODBC Connection
1-
||
-
-%
5
OK/
||
Connecting to an ODBC
Retrieving Records
||
||
An ODBC Example
*&+
/
6&8
68
67
=?>'AAAAAA):
'B=)
H*'0
3#0/=):I
=E?05 5
<34-&0:
=?>*'==E):
'B=)
H*'05 0):I
068680:
068
&&6;80:
068
&6;86;80:
'>>'=))
H
=&&?>'=0
&@&0):
=&?>'=0
@&0):
06868=&&6;80:
068=&6;86;80:
I
>'=):
06;80:
78
6;8
6;&8
||
x5B
||