You are on page 1of 94

http://www.c4arab.

com

PHP 4

PHP

HTML, CSS, JavaScript, MySQL, XML




2002
!! !!

-1-






.



...
:
ebooks@c4arab.com
.

-2-


... .
.
...
...
.

.

" " .

..
.

-3-



1401- 4 -4 : 1981-2-8

) (

2000


.
20,000
.
: \ ++\
.
: . MySQL

-4-


9..................................................................... : 14 ............................................ : 84........................................... PHP : ............................................ PHP : ............................................. PHP : ................................................... : .......................................... : ............................................ : .............................................. : ................................................... : ............................................ XML : .................................... PHP : .......................................... 1 : .......................................... 2 : ........................................- : ............................... PHP

-5-


9 ....................... ................................. .................................- : 14............................................................

: 15......................................................HTML : 41............................................................CSS : 56.................................Java Script : 84............................................................PHP : PHP : PHP : MySQL : PHP : : : : : : )(--------- : PHP : : : : --------- : : : : : )(mail : )(header : ---------- : : : . : : : : . : -6-

: : : : : : : : : SQL : SQL : MySQL . PHP : : : : : - :

- : XML

- : XML

----------- :- : PHP

: PHP XML

: : )(Sessions : ----------- : : ) 1 ( : ) 2 (- :

: PHP

-7-




" " .

"
" .

!


.

.
.. !
" "

.
..

.

" "
" "
!
" " ) (HTML
.
" "
. .
" " " "
" " " " .
" " " "
.
" "
" " .

) (HTML ) . (PHP

. .

-8-


. !
.

.
.

. .
) (String .

.

.. .

.


.


.
.
.


.

. ) (SQL .

.

.

!
!


!
!

-9-

..
!
..
!
.
.
...
..
.
...
.
.


" " ...
.
.
:



.
:

" " php.php


.

.


- 10 -



.
.
!


.

.
... ..

.

!
!
.

...
.
.

.

.

- 11 -

! .

- 12 -

.

.
..
. )
(HTML ) . (CSS
.

- 13 -

: HTML

"" .



) ( .
...

.

.

.
:

Hyper Text Markup Language

) (
) (Tags
.
:
.

:
> <
.
)
...( .

) (/ .
:
> </
.

!
... .
:
> <

> </

- 14 -


) Form
. (Elements .

.

:
> =""<

.
.
:
><hr
><hr width=50%
><Font color=red
><img src=images/php.gif



. ) .htm
.
(.html
). (Notepad
) 1.htm :
(

!
) -(

.
!

.

!
:

- 15 -


...

><html
.
.
...
)
.
(

:
)(Dir=rtl
:
><HTML dir=rtl

><head
...

.

)>(<head


) .(Meta tags
.
:
></head

><title

" " .
> <title
- 16 -

.
:
></title

><body
..
> <head >.<body
.

..
.

:
></body
! .
... :

:
.
><html

:
: ><head
: ><body

...

:
:

><meta

- 17 -

.

!
.. >. <head
:
>""=<meta name="" content
:
>"<meta name="author" content="shahrazad@c4arab.com

.
) ==<(
.
;<meta http-equiv="Content-Type" content="text/html
>"charset=windows-1256
>"<meta http-equiv="Content-Language" content="ar-sa

. .
22
. 22 .
:
>"<meta http-equiv="Content-Language" content="ar-ae
..
! .
.
:
"<meta http-equiv="Refresh
>"content=0;URL="http://www.c4arab.com
.

.
http://www.c4arab.com
.

:
..
.
:

- 18 -

" " .
:

.. :

><font

- 19 -

.
.
:

Color


.


.


.

Face
Size
1

..

..
. :

- 20 -



.
!
.
:
>"<Font face="Tahoma, Verdana, Arial
..

><p

.
:

- 21 -

align


)(.
- 22 -

dir


)
(.

><H1
). (Heading
..
><H1
><H2
><H3
><H4
><H5
><H6
...
.
:

- 23 -

10

!

.

) (CSS .
><BR
! .
.
.


) . (<p> :
.
. !

><HR

). (Horizontal Line
.
:

- 24 -

11

12

><B
). (Bold

><I
). (Italic

><S
). (Strike through

- 25 -

><U
). (Underline
:

13

14

- 26 -

><BlockQuote
) . (Quote
.
:

15

16

><pre
pre preformatted .

. monospace
.
:

- 27 -

17

18

><code

monospace . .

- 28 -

><ul
. :

19

20

- 29 -

21

..

><ol
..
.

22

- 30 -

><a

> <a .
. :

href


.


.

target
3

23

><img

. > <img .
:

Src

- 31 -

.

.

.

.

Width
Height
Border
4

24

:
.
..

:
> <
> <
> <
> </
> <
> </
> </
> </
.
.

><table
... > . </table
:

- 32 -

bgcolor
Width

.

.

.

.

Height
Border
5

><tr
. >. </tr

><td
. >. </td
:

25

- 33 -

:
.
.

. ..

.

><form
. > . </form
:

method


). (post , get , head


.

action
6

><input

.
... .

:

type

)
..( .


.

.

name
value
7

- 34 -

26

27

..
.
" "form.php action
.

- 35 -

) (6
.
:

28

- 36 -

29

:
>"<input type="checkbox" name="C1" id="a"><label for="a
> 1</label
" "3 .
" "C1 " . "a
> . <label > <label
.

><input


" "3
.
=-=-=-=-=-=-=-=->"<input type="checkbox" name="C2" id="b"><label for="b
> 2</label

.
=-=-=-=-=-=-=-=-<input type="radio" value="V1" name="R1" checked
> 1</label >"id="c"><label for="c
. ) (radio buttons
) (29
) ( .
> <label .
-

- 37 -

=-=-=-=-=-=-=-=-

<input type="radio" value="V2" name="R1" id="d"><label


> 2</label >"for="d
.
.

"name="R1
)
( .
..
.

)
(
.
=-=-=-=-=-=-=-=- >"<textarea rows="2" name="S1" cols="20
></textarea

.
) (rows (cols)
.
=-=-=-=-=-=-=-=->"<select size="1" name="D1
></option ><option value=1
></option ><option value=2
></select

.
>. <option

!
" !"

:
.
.

.

- 38 -

HTML4 Bible by Bryan Pfaffenberger and Alexis D. Gutzman (IDG


Books)
DHTML: The Definitive Reference by Danny Goodman (OReilly)

- 39 -

: CSS

!
...
.

.
" "2 " ! "3
! 50 !


""
.

!

:
.
:

Cascading Style Sheets

) ( . . CSS :
! .

. :

30

- 40 -


.
.

.

.
..


CSS
) : (
. W3C

.


W3C World Wide Web Consortium
. HTML

:

.
.
. :
}"" : { :


.
:
} { color: #008000; font-size: 1em
} { border-style: solid
} { color: #800000

- 41 -

a
body
h2

{ border-style: solid; border-color: #FF00FF


} { border-right-style: solid

p
}
table



.
. ) (a
.
);( . !
:
{ a
;color: #008000
font-size: 1em
}

" " !
" " !
.

) (h1-h6
) . (a :
} ;h1,h2,h3,h4,h5,h6 { color: #008000
. ) (,
.
): (Classes
:

!

!
) (Classes :

31

!
.

- 42 -

32

33

:
! .

- 43 -

:
} .red{ color: red

:
...

:
- ).(external file
- ). (Head
- ).(Inline

:
- ):(external file
.

) ( .

!
.
.css
31 .
:

34

- ): (Head

- 44 -


.
)> (<style )>(<head
:

35

- ): (Inline
!
.
! .
!
style
:

36


!
.
- 45 -


.
. " "3
" "2 " "1 .

"! "1
) ( :
-1 .
-2 .
-3 .
-4 .

):(Pseudo-class

.
:
}"" : { :
) (:
}"" : { : .
! :

37

: ) (#000088 .
.
!
) 10( . )( .
.

!
) link
- 46 -

visited hover (active !


:

38

) (main
) (sub .

.

): (ID

.

:

39

40

- 47 -

:
.
)
( .

. :
" "3
.

.
""3
.
:
:

41

42

- 48 -

43

:

.

.

.

:

44



- 49 -


.

! ) (size
) (font-size .

. :
) !
(

><body

font-family
font-size
color
Background-color
Background-image
Background-repeat

SCROLLBAR-BASE-COLOR
SCROLLBAR-ARROW-COLOR
Scrollbar-track-color
Scrollbar-face-color
Scrollbar-highlight-color
Scrollbar-3dlight-color
Scrollbar-darkshadow-color
scrollbar-shadow-color

.
.
.
.

.

:
(repeat, repeat-x, repeat-y, no)repeat

.

.

.

.

) (

.

.

)
(.

!
) (body
- 50 -

) (body .
) (table .
><table

font-family

font-size
color
Background-color
Background-image
Border-color
Border-width
Border-style

Border-left-color
Border-left-width
Border-right-color
Border- right-width
Border-top-color
Border-top-width
Border-bottom-color
Border-bottom-width


.

.

.
.

.
)
(
)
( :
) (thin, medium, thick,
)
( :
(none, hidden, dotted, dashed, solid,
)double, inset, outset
.

.
.

.
.

.

.

.

><ol>,<ul

font-family

font-size
- 51 -

color
list-style-image
list-style-position
list-style-type

.

.

) ( .

:
)(Inside, outside

:
(None, disc, circle, square, decimal,
lower-alpha, upper-alpha, lower-latin,
)upper-latin

10

!

!


!
w3c .
! .
!

><input

font-family

font-size
color
border

background-color

- 52 -


) ( .

) (.

) (.



:
);(border: 1px solid #000000

.

11

:
CSS !
!

. ) :
!( .
.

! .

:

:
Cascading Style Sheets The Defintive Guide by Eric A. Meyer
)(O'Reilly & Associates
Core CSS: Cascading Style Sheets by Keith Schengili-Roberts
)(Prentice Hall PTR
Cascading Style Sheets: Designing for the web by Hakon Wium Lie,
)Bert Bos, Robert Cailliau (Addison-Wesley Pub Co

- 53 -

: Java
Script
!
.
!

:




.

.

.


.

!
.

:

! 20
10

..
) Form
. (Validation


! .

.

:
) . (Netscape
Live Script

- 54 -

Sun Live Script Sun


! Java Script
.
.
Java Script Java
. JScript Netscape
Sun .
!
.


.



.
) event
. (driven

.
:
o ) :(Client Side - -
.

.
o ) :(Server Side
.

.
) .
(.
! ...

:

.
> <script
.
.
:
1. :
:

- 55 -

45

46

! 6
> <script language JavaScript
.
7 "
);( .
" .




.
8 >. </script
!

- 56 -


:
><Script type=text/JavaScript

></script

!!
2. :

.

.
.
:
:

47

src .
.
:

48

- 57 -


js
. > <srcipt
!
.
:

!

:
><Script type=text/JavaScript
<!-
>//--
></script

:
)
(body .

.
) (function .
- 58 -


.

.. .
:

49

> <script .

!
:
) ..( .
.
.
!
.
.


.
: !
.
: !
! .. var
:
Var variable_name = value
: var

- 59 -

variable_name = value
:

50

string1 " "


.

:

51

)
(:

52

- 60 -

:

.. :


)_( .
). 1var : (
)) .(case sensitive var1 :
(VaR1
) (reserved word ) :
var (

:

) . (&& * - + :

:
:
- :

..
:

)(


.
- 61 -


:
;X=1;y=2;z=x*y
: z 2

:
;X=4;y=2;z=x/y
: z 2

:
;X=3;y=2;z=x%y
: z 1

:
;X=1;y=2;z=x+y
: z 3

:
;X=1;y=2;z=x-y
: z 1-

:
;X=1;x++
: x 2

:
;X=1;x--
: x

++

--

&&

"" )
(AND :
;)X=1;y=2;z=(x<y && y>1
z : True
"" )
(OR :
;)X=1;y=2;z=(x< y || y>1
z : True
""
) (NOT :
;)X=1;y=2;z=!(x<y
z : True

||

- 62 -

53

- :



:
;X=1
: x 1


:
;X=1;x += 2
: x 3
)(2+1


:
;X=2;x -= 1
: x 1
)(2-1

=+

=-

=*

- 63 -

:
;X=2;x *= 2
: x 4
)(2*2


:
;X=4;x /= 2
: x 2
)(4/2


:
;X=3;x %= 2
: x 1
)(3%2

=/

=%

- :

==


true false
:
;)X=1;y=2;z=(x==y
: z
.false

true false
:
;)X=1;y=2;z=(x !=y
: z
.true

true false
:
;)X=1;y=2;z=(x < y
: z
.true

true false
:
;)X=1;y=2;z=(x > y
: z
.false

true false
:

=!

<

>

=<

- 64 -

;)X=1;y=2;z=(x <= y
: z
.true

true false
:
;)X=1;y=2;z=(x >= y
: z
.false

=>

- :

)(
:
;str1=he;str2=llo;str3=str1+srt2
: str3
. hello

- :

(condition)?value1:value2





:
;X=1;y=2
;max=(x>y)?x:y
: max
.2

:

.
. : x
10 !

.. :

- 65 -

:
.
: ) ( ) (
.
:
)If (condition
{
Some statements
}
:
- : if

:

54

- : if .. else

.

- 66 -

55

- : switch
.
:
{)switch (expression
case label1:
code to be executed if expression = label1
break
case label2:
code to be executed if expression = label2
break
default:
code to be executed
if expression is different
from both label1 and label2
}
: switch
) ( .
.
case Break
. default
.
:

- 67 -

56


break

!

!!
...

:
" "

- 68 -


.
:
- : For
.
:
) ; ;( for
{

}
:

57

) (:

- 69 -

58

- : while
.
:
)( while
{

}
:

59

- 70 -

.. :

60

- : do .. while

.
:
do
{

}
)( while
:

61

- 71 -

.60! while do ..
while .
:
)( write ..
.
.
" " .
.


!
. )\( .
:


"\
&\
\\

"
&
\

...


)\( .
:
\ "(document.write
)"!
:
\ document.write
)"! "(
:

- 72 -

62


. :

63

:

.
:

- 73 -

- ) :(built-in .
: ))( (write . ))((alert
.
- :
.
!
..
!

. )( write

.
!
:
),.. , ( function
{

}
)
(:
)( function
{

}
) (:

- 74 -

64

65


! ..
.. .. !
:

- 75 -

66

67

- 76 -

: return
.
:
!
..


!

! .
.. :
:
-1 ).(head
:
-2 )(form
")( onsubmit="return validate validate
.
..
:

68

- 77 -

: "@"
.
) (script1.php
false .
:

69

: .
false

. script1.php
:

!
..

!
) (client-side

!
..

- 78 -

!
!
. Date
new
) (31-1

.
(OOP) ++
:

70

:
Date new
. date1 !
.
: )(31-1
)( GetDate ) (11-0
)( GetMonth )( GetFullYear
)( GetHours
)( . GetMinutes
)=0 =1 ( .
:

- 79 -

71

)(getDate
)(getDay
)(getMonth
)(getYear
)(getFullYear
)(getHours
)(getMinutes
)(getSeconds
)(getMilliseconds
)(getTime
)(getTimezoneOffset
)(toString

- 80 -

)(31-1
)=0 6-0 1
= ...(
)=0 11 -0 1
= (
)(99-0
)(9999-0
)(23-0
)(59-0
)(59-0
)(999-0
)
(1970- 1-1

)(
.

) (comment
.
.
:

:
.

.
:
.

.

:

:
Professional JavaScript with DHTML, ASP, CGI, FESI, Netscape
Enterprise Server, Windows Script Host, LiveConnect and Java by
Sing Li, Andrea Chirelli, Stuart Updegrave, Cliff Wootton, Nigel
)McFarlane, Mark Wilcox, Paul Wilton, James De Carli (Wrox Press
)Beginning JavaScript by Paul Wilton (Wrox Press
)JavaScript Bible by Danny Goodman (Hungry Minds, Inc

- 81 -

: PHP


.
.

.
.
). (MySQL

- 82 -

: PHP

) (
.
\ !
-
- :
PHP
..
.
" " . :
:
) . (server/client )(


.
.

:
)
Apache (
) - (PHP , Perl , ASP , ColdFusion :
.
.

.
: ) ( .
: )
(
www.c4arab.com : ) (IP
.
) MySQL( ) (Port .

) 3-Tier
. (Architecture

- 83 -



)
( .

\


)
( .
:

72

)(



. )
. (HTML .
! ..
:
:
- :
)(
)(
. . )-73( .

!

- 84 -

- )( :
)(

. )-73( .

) !(.

73

HTML
Hyper Text Markup :
Language ) ( .
.
.


. :


!

! " "5:40 :

!
.

.

) (
) PHP,ASP( .
w3c
)EXtensible Hyper Text Markup =XHTML
. (Language
.
) ( .

- 85 -


.
DHTML
Dynamic Hyper :
Text Markup Language ) ( .
.
.
.
:
.
!
) -73( .
ActiveX Controls

++ .
.
: .
> . <object

.
!

)Plug-ins
(.
CGI
Common Gateway :
Interface ) ( .
.
!
.
.
.
: ) (Process .
.
.
.

.

. . FastCGI
ASP
- 86 -

Active Server Pages :


) ( .
.
.
. .asp .
JScript : . VBScript
)
(VBScript .



). (IIS, PWS

) (

.


ASP
.
.
JSP
Java Server Pages :
) ( .
.
) . (SUN ) (ASP
) (PHP
. .
.jsp .


. .
)(
.


!
ColdFusion
.
.
- 87 -

) . (Allaire :
.
! Express, ) :
. (Professional, Enterprise .
.
. .

.

.
.
Perl

. ) . (Larry Wall

. C, sed , awk ) :
,Unix shells ( .
! .
) (Libraries .

.
.
PHP

) (Rasmus Lerdorf
.
) Personal Home
. (Page tools ) . (PHP = Personal Home Pages

! ) . (Open-Source
. FI . PHP/FI
) . (Form Interpreter
1994 . 1995
PHP/FI 2

.
.

. 1997 .

50.000 %1
.
PHP3
- 88 -


.
:
) Andi Gutmans . ( Zeev Suraski
. 1997
.
.

.
.
PHP . )
. (Hypertext Preprocessor PHP3
1998
- %10 .
!
PHP4
. !
. PHP4
1998
.
:
.
.
) . (Sessions
.
). (XML
)===(
.
). (Boolean

.
.

) Zend ( .
. 1999 2000
.
%20
. !
PHP5
) 4.2.2( .
.

- 89 -


.
: PHP

. :

20

10

2002

2000

1998

1997

: Zend
1999
) Andi Gutmans . ( Zeev Suraski

.

. .
PHP
.
:
-1 : .
-2 : ) ( .
-3 : .
.
.
.
:

- 90 -

74

:

: .
: . .
: PHP
:
!
50 ) (

!

:
AMS Teach yourself PHP in 24 hours by Matt Zandstra (SAMS
S
)Publishing
Professional PHP Programming by Jesus Castagnetto, Harish Rawat,
)Sascha Schumann, Chris Scollo, Deepak Velialth (Wrox Press
Instant PHP4 by Micheal J. Walker, Robert M. COX, Neal Anders
)(Osborne

:
- :
http://www.php.net
http://www.phpbiulder.com
http://www.apache.org
http://www.mysql.com

- :
http://www.c4arab.com
http://www.php4web.com

- 91 -

http://www.phpvillage.com

- 92 -

: PHP

- 93 -

: MySQL

- 94 -

You might also like