You are on page 1of 29

PHP?

PHP HyperText Preprocessor


. ,
/
. , . UNIX, UNIX-like, GNU/Linux, Windows.
Apache
CGI.
URL ,
,
. HTML,
. ,
, . , ,
.
.

PHP
PHP C Perl.
. . PHP -
,
. , PHP
, , ODBC, mySQL
Java COM. PHP ,
(IDE). <?php ?>.
PHP ?
PHP. ,
, 19
, , -mail,
(newsgroups) ... PHP:
1. PHP e
. . , ... 2.
PHP
. 3. ,
4.
PHP . 19
5. ,
thirt-party , ,
, . PHP . 6. PHP
e-mail-, newsgroup-,
. 7. PHP

Java COM . 8. PHP !


pdf xml.

PHP
, . PHP
, -. PHP
-, .
. ,
{ }.
PHP , HTML PHP . PHP
<?php ?>.
. .
: echo print.
a echo.
<?php
echo "Everyone, smile!!!"; //ova e delot sto se pecati
?>

.php

.
, . "first.php" root .
, .
http://localhost/first.php. ,
Everybody smile!!!.
php , .
PHP . HTML
:
<html>
<head>
<title>Prva PHP skripta</title>
</head>
<body>
<?php echo "Everybody smile!!!"; ?> // ova e delot sto se pecati
</body>
</html>

,
bold. :
, PHP
HTML. PHP .

PHP
.
, , , , null
( ). PHP, $
=. $ ,
PHP .
PHP ;". PHP
,
. :
<?php
$tekst = " :) ";
$broj = 14;
echo $tekst;
echo $broj;
?>

: :) 14



PHP . :
<?php

?>

$promenliva = " ";


$Promenliva = " ";
echo "$promenliva - $Promenliva";`

: -


1. PHP _". 2.
- 3.
4.
. $

.


,
.
.
: $_SERVER
HTTP . $_COOKIE ,
, . $_GET
URL
$_POST
, . . $_FILE
$_ENV

:
<?php
$novaPromenliva = $_COOKIE["moetoPrvoKolace"];
echo $novaPromenliva;
?>

PHP
.
.
, , ...
" ,
.
, .
:
<?php
define("PASSWORD", "admin");
echo (PASSWORD);
promenlivata PASSWORD "admin"
echo constant("PASSWORD");
echo "PASSWORD";
?>

//ke ja prikaze vrednosta na


//isto ke otpecati "admin"
//ke prikaze "PASSWORD"

PHP . . "_FILE_"
. "_LINE_"
.
.
"PHP_VERSION" .

PHP

.
.
.
. .
() ,
. PHP ,
.


.
<?php
$sedum = 7;
$imeNaNiza = array("ova e element", 5, $sedum);
echo $imeNaNiza[0];
//ova ke otpecati: ova e element
echo $imeNaNiza[1];
//ova: 5
echo $imeNaNiza[2];
//ova: 7
?>


, . ,
.
is_array().
0.

A
. .
<?php
$prva_niza = array ("kluc1" => "prviot element", "kluc2" =>
"vtoriot element");
$vtora_niza = array(
"kluc3" => "prv element vo vtorata niza",
"kluc4" => "vtor element vo vtorata niza"
);
echo $prva_niza['kluc1'];
//"prviot element"
echo $prva_niza['kluc2'];
//"vtoriot element"
echo $vtora_niza['kluc3'];
//"prv element vo vtorata
niza"
echo $vtora_niza['kluc4'];
//"vtor element vo vtorata
niza"
?>

<?php
$cokolado = array (
"nestle" => "50",
"milka" => "60",
"kandi" => "10"
);
echo "nestle kosta $cokolado['nestle'], milka kosta
$cokolado['milka'], a kandi mnjam mnjam $cokolado['kandi'].";
?>

,
.
foreach .
:
<?php
$cokolado = array (
"nestle" => "50",
"milka" => "60",
"kandi" => "10"
);
//za pecatenje naslov na tabelata
echo "<table border='1' cellpadding = '5'>";
echo "<tr><th>Cokolado</th><tr>";
//ova e toa sto ke pomine niz celata niza, zemajki go $Cokolado
kako kluc i $Cena kako vrednost
foreach($cokolado as $Cokolado => $Cena)
{
echo "<tr><td>$Cokolado </td><td>$Cena</td></tr>";
}
echo </table>
?>


:
. ,
. -
.

(string)
<?php
$flowers = array("rose", "daisy", "orchid", "tulip",
"chamomile");
sort($flowers);
for ($i = 0; $i < 4; $i++) // da se otpecatat elementite
echo $flowers[$i]."<br />";
?>

.
: camomile daisy orchid rose tulip
. .
, . .:
<?php
$prices = array(1.25, 0.75 , 1.15, 1.00, 0.50);
sort($prices);
for($i = 0; $i <= 4; $i++)
echo $prices[$i]."<br />";
?>

: 0.75 1.00 1.15 1.25


,
. , "A" "Z", a "Z" "a".


, sort() .
sort() ,
. asort() ,
.
.
, .
<?php
$shop = array ("rose" => "5.00",
"daisy" => "4.00",
"orchid" => "2.00",

);
asort($shop);
foreach($shop as $key => $value)
echo $key." costs ".$value." dollars<br />";
?></nowiki>

: orchid costs 2.00 dollars daisy costs 4.00 dollars rose costs 5.00
dollars
asort()
. , , .
, ., , ksort().
:
<?php
$shop = array ("rose" => "5.00",

"daisy" => "4.00",

" orchid" => "2.00" );


ksort($shop);
foreach($shop as $key => $value)
echo $key." costs ".$value." dollars<br />";
?>

: daisy costs 4.00 dollars orchid costs 2.00 dollars rose costs 5.00 dollars
,
. : sort(), asort(), ksort()
: rsort(), arsort(), krsort(), .
.

-
.
, , .
, - -
.

-
. -
. ,
, . . -
. ,
.
Title Price Number rose 1.25 15 daisy 0.75 25 orchid 1.15 7
- ,
:
<?php
$shop = array ("rose", 1.25, 15),
array ("daisy", 0.75, 25),
array ("orchid", 1.15, 7)
);
?>

$shop, .
- ,
. - , :

, .
, for for, .
<?php

echo "<h1>Pristap do sekoj element</h1>";


echo $shop[0][0]." costs ".$shop[0][1]." and you get ".$shop[0]
[2]."<br />";
echo $shop[1][0]." costs ".$shop[1][1]." and you get ".$shop[1]
[2]."<br />";
echo $shop[2][0]." costs ".$shop[2][1]." and you get ".$shop[2]
[2]."<br />";
echo "<ol>";
for ($row = 0; $row < 3; $row++)
{
echo "<ul>";
for ($col = 0; $col < 3; $col++)
{
echo "<li>".$shop[$row][$col]."</li>";
}
echo "</ul>";
echo "</li>";
}
echo "</ol>";
?>

,
. . ,
, .
<?php
$shop = array( array( Title => "rose",
Price => 1.25,
Number => 15
),
array( Title => "daisy",
Price => 0.75,
Number => 25,
),
array( Title => "orchid",
Price => 1.15,
Number => 7
)
);
?>

,
.
.
for. :
<?php

echo "<h1>Manual access to each element from associative


array</h1>";

for ($row = 0; $row < 3; $row++)


{
echo $shop[$row]["Title"]." costs ".$shop[$row]["Price"]."
and you get ".$shop[$row]["Number"];
echo "<br />";
}

?>

echo "<h1>Using foreach loop to display elements</h1>";


echo "<ol>";
for ($row = 0; $row < 3; $row++)
{
echo "<li><b>The row number $row</b>";
echo "<ul>";
foreach($shop[$row] as $key => $value)
{
echo "<li>".$value."</li>";
}
echo "</ul>";
echo "</li>";
}
echo "</ol>";

-
- .
. -
, . -
, .
, .
,
- . :
$shop = array(array(array("rose", 1.25, 15),
array("daisy", 0.75, 25),
array("orchid", 1.15, 7)
),
array(array("rose", 1.25, 15),
array("daisy", 0.75, 25),
array("orchid", 1.15, 7)
),
array(array("rose", 1.25, 15),
array("daisy", 0.75, 25),
array("orchid", 1.15, 7)
)
);
?>

, for
:
<?php
echo "<ul>";

?>

for ( $layer = 0; $layer < 3; $layer++ )


{
echo "<li>The layer number $layer";
echo "<ul>";
for ( $row = 0; $row < 3; $row++ )
{
echo "<li>The row number $row";
echo "<ul>";
for ( $col = 0; $col < 3; $col++ )
{
echo "<li>".$shop[$layer][$row][$col]."</li>";
}
echo "</ul>";
echo "</li>";
}
echo "</ul>";
echo "</li>";
}
echo "</ul>";

, .
.

PHP
,
. .
.
: ifelse switch.

ifelse

, ,
... , .
if :
if () {
1
} else {
2
}

.
<?php

$rezultat = 70;
if ($rezultat >= 57) {
echo "Uslovot pomina kako token <br />";

}
else {
echo "Uslovot ne pomina <br />";
}
?>

elseif.
.
<?php
$rezultat = 70;
if ($rezultat >= 75) {
echo "izlez 1";
}
elseif ($rezultat >= 60) {
echo "izlez 2";
}
elseif($rezultat >= 45) {
echo "izlez 3";
}
else {
echo "izlez 4";
}
?>

switch
if.
if e . switch:
switch () {
case 1:
_1
[break;]
case _2:
_2
[break;]
...
default:
_n
[break;]
}


. switch.
default
. default
switch. break
. ,
switch. .:
$flower = "rose";

switch ($cokolado)
{
case "milka" :
echo $cokolado."
break;
case "nestle" :
echo $cokolado."
break;
case "kandi" :
echo $cokolado."
break;
default :
echo "Nema takvo
break;
}

costs 60den.";
costs 50den.";
costs 10den";
cokolado vo prodavnicata :(";

,
:
<?php
$broj = 5;
switch ($broj) {
case 0:
echo "Nula ne e validen slucaj.";
break;
case $ broj < 0:
echo "Negativni broevi ne se dozvoleni.";
break;
default:
echo "Vnesen e pozitiven broj.";
break;
}
?>

PHP .

, .
, ,
. . PHP
: for while. for,
. while,
,
. break continue .

while
while , .
,
. :

while (condition)
{
naredbi;
}

while { }.
PHP . while
:
while (seuste ima redovi vo bazata)
{
citaj od eden red;

pomini na sledniot red;


}

0.
i 10,
:
<?php
$i = 0;
while ($i <= 10)
{
echo "Brojot e: ".$i."<be/ >";
$i++;
}
?>

. ,
. :
<?php
$month_array = array( "January", "February", "March", "April",
"May", "June",
"July", "August", "September", "October",
"November", "December");
echo "<select name=\"day\">";
$i = 1;
while ( $i <= 31 ) {
echo "<option value=".$i.">".$i."</option>";
$i++;
}
echo "</select>";
echo "<select name=\"month\">";
$i = 0;
while ( $i <= 11 ) {
echo "<option value=".$i.">".$month_array[$i]."</option>";
$i++;
}
echo "</select>";
echo "<select name=\"year\">";

$i = 1900;
while ( $i <= 2007 ) {
echo "<option value=".$i.">".$i."</option>";
$i++;
}
echo "</select>";
?>

. ,
.

do...while
do...while while,
. do...while
. :
do
{
naredbi;
}
while (condition);

, i
10:
<?php
$i = 0;
do {
echo "Brojot e ".$i."<br/>";
$i++;
}
while ($i <= 10);
?>

for
for
. for .
:
for (inicijalizacija; uslov; skok)
{
naredbi;
}

for ;.
for: 1. , . 2.
. , , -

. 3. . 4.
2.
:
<?php

?>

for ($i = 0; $i <= 10; $i++)


{
echo "Brojot e ".$i." <br/>";
}

. :
<?php

echo "<h1>Multiplication table</h1>";


echo "<table border=2 width=50%";
for ($i = 1; $i <= 9; $i++ ) {
echo "<tr>";
echo "<td>".$i."</td>";

//nadvoresen ciklus

for ( $j = 2; $j <= 9; $j++ ) { // vnatresen ciklus


echo "<td>".$i * $j."</td>";
}

?>

echo "</tr>";
}
echo "</table>";

.
1 10, .
<?php

?>

$total = 0;
$even = 0;
for ($x = 1, $y = 1; $x <=10; $x++, $y++)
{
if (($y % 2) == 0)
{
$even = $even + $y;
}
$total = $total + $x;
}
echo "Celiot zbir e ".$total."<br/>";
echo "Zbirot na ednakvite e ".$even;

foreach
foreach for .
foreach :

foreach (array as value)


{
naredbi;
}

foreach (array as key => value)


{
naredbi;
}

, :
<?php

$email = array('john.smith@server.com', 'alex@server.com' );


foreach ($email as value)
{
echo "Sending mail to ".$value."<br/>";
}

?>

PHP foreach
.
.
. foreach :
<?php
$person = array('name' => 'Andrew', 'age' => 21, 'address' =>
'77, Lincoln st.');
foreach ($person as $key => $value)
{
echo $key." is ".$value."<br/>";
}
?>

, $key,
$value. foreach ,
, . ,
$value, .

break continue
,
. continue
break. break, while for
. break,
. break:
<?php

echo "<p><b>Example of using the Break statement:</b></p>";

for ($i=0; $i<=10; $i++) {


if ($i==3){break;}
echo "The number is ".$i;
echo "<br />";
}
echo "<p><b>One more example of using the Break
statement:</b><p>";
$i = 0;
$j = 0;
while ($i < 10) {
while ($j < 10) {
if ($j == 5) {
break 2;
} // breaks out of two while loops
$j++;
}
$i++;
}

?>

echo "The first number is ".$i."<br />";


echo "The second number is ".$j."<br />";

continue
:
<?php

echo "<p><b>Example of using the Continue statement:</b><p>";


for ($i=0; $i<=10; $i++) {
if (i==3){continue;}
echo "The number is ".$i;
echo "<br />";
}

?>

,
.
, . ,
,
. , :
<?php
function ime_na_funkcija(param_1, ... , param_n)
{
naredbi;
return povratna_vrednost;

?>

,
.


, "php rulez" ,
. .
. : <?php function first() { for($i = 0; $i !=5; $i++) echo
"<p>php rulez!</p>"; } function second($num, $msg) { for($i = 0; $i != $num; $i++)
echo "<p>". $msg ."</p>"; } echo "Ova e pred da se povikaat funkciite.<br>"; echo
"Izlezot od prvata funkcija e: " first(); echo "Ova e izlezot od vtorata funkcija: "
second(5, "bla bla bla"); echo "Ova e posle dvete funkcii<br>"; ?> ,

: <?php function ar_sr($a, $b) { $result = ($a + $b) / 2; return $result; } echo
ar_sr(4, 6), "<br>"; echo ar_sr(2314, 12412), "<br>"; ?>


,
.
.
.
, global:
<?php

function AddingNumbers()
{
global $sum = 2 + 2;
}
$sum = 0;
AddingNumbers();
echo "2 + 2 = ".$sum;

?>

,
. global PHP
.
, . ,
. ,
.

PHP
PHP
HTML .

HTML ,
.

HTML
,
HTML .
: GET POST.
HTML , .
. HTML
, POST .

. form.html.
<html>
<head>
<title>Process the HTML form data with the POST method</title>
</head>
<body>
<form name="myform" action="process.php" method="POST">
<input type="hidden" name="check_submit" value="1" />
Name: <input type="text" name="Name" /><br />
Password: <input type="password" name="Password" maxlength="10"
/><br />
Select something from the list: <select name="Seasons">
<option value="Spring" selected="selected">Spring</option>
<option value="Summer">Summer</option>
<option value="Autumn">Autumn</option>
<option value="Winter">Winter</option>
</select><br /><br />
Choose one:
<input type="radio" name="Country" value="USA" /> USA
<input type="radio" name="Country" value="Canada" /> Canada
<input type="radio" name="Country" value="Other" /> Other
<br />
Choose the colors:
<input type="checkbox" name="Colors[]" value="green"
checked="checked" /> Green
<input type="checkbox" name="Colors[]" value="yellow" />
Yellow
<input type="checkbox" name="Colors[]" value="red" /> Red
<input type="checkbox" name="Colors[]" value="gray" /> Gray
<br /><br />
Comments:<br />
<textarea name="Comments" rows="10" cols="60">Enter your
comments here</textarea><br />
<input type="submit" />
</form>
</body>
</head>
</html>

: ,
, .
, process.php
. ,
(checkbox), []. PHP
.
PHP . . Green Yellow
, $_POST['Colors'] . $_POST['Colors'][0] Green,
$_POST['Colors'][1] Yellow. name
[]. , $_POST['Colors']
.


, PHP .
(submit),
: $_GET $_POST,
co GET POST . , Name,
POST, $_POST['Name'].
process.php form.html:
<?php
//Check whether the form has been submitted
if (array_key_exists('check_submit', $_POST)) {
//Converts the new line characters (\n) in the text area into
HTML line breaks (the <br /> tag)
$_POST['Comments'] = nl2br($_POST['Comments']);
//Check whether a $_GET['Languages'] is set
if ( isset($_POST['Colors']) ) {
$_POST['Colors'] = implode(', ', $_POST['Colors']); //Converts
an array into a single string
}
//Let's now print out the received values in the browser
echo "Your name: {$_POST['Name']}<br />";
echo "Your password: {$_POST['Password']}<br />";
echo "Your favourite season: {$_POST['Seasons']}<br /><br />";
echo "Your comments:<br />{$_POST['Comments']}<br /><br />";
echo "You are from: {$_POST['Country']}<br />";
echo "Colors you chose: {$_POST['Colors']}<br />";
} else {
echo "You can't see this page without submitting the form.";
}
?>

,
. , HTML
. , implode()
$_POST['Colors'] . ,
.

GET POST
PHP , GET
POST . ,
. GET
, URL. ,
, . ,
. ,
,
. ,
URL-,
(bookmarks). GET . ,
,
. POST,
.
URL, .

PHP
,
.
, . ,
, .
.
, , .
( )
.
.
. ,
,
.
(Sessions).

?
PHP setcookie().
: setcookie(name[, value[, expire[, path[, domain[, security]]]]])
[name] .
$_COOKIE. [value] .
. [expire] ( ).
[path] .
[domain] . ,
. [security]
HTTPS. 1
, .

, . 0
HTTP . ,
"MyCookie" "PHP tutorial". ,
1
tutorials.
<?php

setcookie("myCookie", "PHP Tutorial", time()+3600,


"/tutorials");
?>

HTTP,
.
. , PHP
.

?
, .
,
$_COOKIE. , :
<?php
?>

echo "The cookie value is ".$_COOKIE['myCookie'];

: "The cookie value is PHP Tutorial".

?
, .
, , .
, ( ),
time() .


. PHP
, ., ,
... , GD
. ,
.
: (captcha)
MySQL .


(captcha).
.
<?php
create_image();
exit;
function create_image()
{
$md5 = md5(rand(0,999));
$pass = substr($md5, 10, 5);
$width = 100;
$height = 20;
$image = ImageCreate($width, $height);
$white = ImageColorAllocate($image, 255, 255, 255);
$black = ImageColorAllocate($image, 0, 0, 0);
$grey = ImageColorAllocate($image, 204, 204, 204);
ImageFill($image, 0, 0, $black);
ImageString($image, 3, 30, 3, $pass, $white);
ImageRectangle($image, 0, 0, $width-1, $height 1, $grey);
imageline($image, 0, $height/2, $width, $height/2, $grey);
imageline($image, $width/2, 0, $width/2, $height, $grey);
header("Content-Type: image/jpeg");
ImageJpeg($image);
ImageDestroy($image);
}
?>

,
. ,
ImageCreate() $width
$height.
. ,
: ImageCreateFromPNG(), ImageCreateFromGIF(), ImageCreateFromJPEG().
.
.
ImageColorAllocate() , .
, . ImageFill()
. , .
ImageString() .
, , .
, .
, .
,
.
.
, header() MIME
. ,
. ImageDestroy().


, MySQL
. ,
PHP.
CREATE DATABASE `poll`;
USE poll;
CREATE TABLE `results` (
book_type VARCHAR(50),
num_votes INT
);
INSERT INTO `results` values
('Classic', 15),
('Fantasy', 7),
('Humor', 32),
('Mystery', 12),
('Poetry', 25);

,
.
.
<?php
$dbhandle = mysql_connect("localhost", "root", "")
or die("Unable to connect to mysql");
$selected = mysql_select_db("poll", $dbhandle)
or die("Cannot select examples");
$result = mysql_query("SELECT * FROM results");
$num_poller = mysql_num_rows($result);
$total_votes = 0;
while($row = mysql_fetch_array($result)){
$total_votes += $row{'num_votes'};
}
mysql_data_seek($result, 0);
mysql_close($dbhandle);

.
.
,
. TrueType .
.
GDFONTPATH. . TrueType
ImageTTFText(). .
:
putenv('GDFONTPATH='pateka_do_font');
$font = 'arial';
$y = 50;
$width = 700; //Image width in pixels

$bar_height = 20; //Bars height


$height = $num_poller * $bar_height * 1.5 + 70; //Calculating image
height
$bar_unit = ($width - 400) / 100; //Distance on the bar chart
standing for 1 unit
//Create the image resource
$image = ImageCreate($width, $height);
//We are making four colors, white, black, blue and red
$white = ImageColorAllocate($image, 255, 255, 255);
$black = ImageColorAllocate($image, 0, 0, 0);
$red = ImageColorAllocate($image, 255, 0, 0);
$blue = imagecolorallocate($image,0,0,255);
//Create image background
ImageFill($image,$width,$height,$white);
//Draw background shape
ImageRectangle($image, 0, 0, $width-1, $height-1, $black);
//Output header
ImageTTFText($image, 16, 0, $width/3 + 50, $y - 20, $black, $font,
'Poll Results');
while ($row = mysql_fetch_object($result)) {
if ($total_votes > 0)
$percent = intval(round(($row->num_votes/
$total_votes)*100));
else
$percent = 0;
//Output header for a particular value
ImageTTFText($image,12,0,10, $y+($bar_height/2), $black, $font,
$row->book_type);
//Output percentage for a particular value
ImageTTFText($image, 12, 0, 170, $y + ($bar_height/2),$red,
$font,$percent.'%');
$bar_length = $percent * $bar_unit;
//Draw a shape that corresponds to 100%
ImageRectangle($image, $bar_length+221, $y-2,
(220+(100*$bar_unit)), $y+$bar_height, $black);
//Output a bar for a particular value
ImageFilledRectangle($image,220,$y-2,220+$bar_length, $y+
$bar_height, $blue);
//Output the number of votes
ImageTTFText($image, 12, 0, 250+100*$bar_unit, $y+
($bar_height/2), $black, $font, $row->num_votes.' votes cast.');
//Going down to the next bar
$y = $y + ($bar_height * 1.5);
}
//Tell the browser what kind of file is come in
header("Content-Type: image/jpeg");

//Output the newly created image in jpeg format


ImageJpeg($image);
//Free up resources
ImageDestroy($image);
?>


(header),
,
. :
1. 2.
<img> 3.
<img>
<img height="120" alt="Dynamically generated image"
src="generate_image.php" width="200">


PHP .
. ,
.
,

.

HTML
PHP , HTML
,
.
<html>
<body>
<form enctype="multipart/form-data" action="upload.php"
method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="1000000" />
Choose a file to upload: <input name="uploaded_file"
type="file" />
<input type="submit" value="Upload" />
</form>
</body>
</html>

HTML . ,
POST . ,

enctype="multipart/form-data" .
. ,
MAX_FILE_SIZE.
( ).
php.ini ,
. php.ini upload_max_filesize = 2MB.
,
. .,
, . ,
post_max_size php.ini
( upload_max_filesize).
10. POST ,
. file_uploads php.ini On.
type="file". ,
. Browse.
, Submit
upload.php. PHP .


, PHP
$_FILES .
: $_FILES["uploaded_file"]["name"]
$_FILES["uploaded_file"]
["type"] MIME $_FILES["uploaded_file"]["size"]
$_FILES["uploaded_file"]["tmp_name"]
$_FILES["uploaded_file"]
["error"]
upload.
JPEG 350:
<?php
if ((!empty($_FILES["uploaded_file"])) && ($_FILES['uploaded_file']
['error'] == 0)) {
$filename = basename($_FILES['uploaded_file']['name']);
$ext = substr($filename, strpos($filename, '.') + 1);
if (($ext == "jpg") && ($_FILES["uploaded_file"]["type"] ==
"image/jpeg") && ($_FILES["uploaded_file"]["size"] < 350000)) {
$newname = dirname(__FILE__).'/upload/'.$filename;
if (!file_exists($newname)) {
if ((move_uploaded_file($_FILES['uploaded_file']
['tmp_name'], $newname))){
echo "It's done! The file is saved as: ".$newname;
} else {
echo "Error: a problem occurred during file upload";
}
} else {
echo "Error: File ".$_FILES["uploaded_file"]["name"]."
already exists";
}

} else {
echo "Error: Only .jpg images under 350Kb are accepted for
upload";

}
} else {
echo "Error: No file uploaded";
}
?>

,
. JPEG
350KB. ,
.
, .
, .

.

e-mail (/HTML/)
Email .
email PHP. Email
, .
. email- .
, HTML .
email . :
email PHP email
: UNIX Sendmail, Windows SMTP
php.ini email .

You might also like