upload file

<html>

A File Upload Script

<body>



if ( isset( $_FILES['fupload'] ) ) {

print "name: ". $_FILES['fupload']['name'] ."
"
;
print "size: ". $_FILES['fupload']['size'] ." bytes
"
;
print "temp name: ".$_FILES['fupload']['tmp_name'] ."
"
;
print "type: ". $_FILES['fupload']['type'] ."
"
;
print "error: ". $_FILES['fupload']['error'] ."
"
;

if ( $_FILES['fupload']['type'] == "image/gif" ) {

$source = $_FILES['fupload']['tmp_name'];
$target = "upload/".$_FILES['fupload']['name'];
move_uploaded_file( $source, $target );// or die ("Couldn't copy");
$size = getImageSize( $target );

$imgstr = "

;
$imgstr .= "src=\"$target\" alt=\"uploaded image\" />

"
;

print $imgstr;
}
}
?>

<form enctype="multipart/form-data"
action="" method="post">


"hidden" name="MAX_FILE_SIZE" value="102400" />
"file" name="fupload" />

"submit" value="upload!" />


form>
body>
html>

Session

The session is use to store user information for use later.Normally the information that store are username and password.The information is temporary and will be deleted when user close the browser or left the website

Example of session:

session_start(); // start up your PHP session!

$_SESSION[username]=$_POST[username]; //stored the username session from the form

Use isset to check the session:

if (isset($_SESSION[username])){
header ('Location: home.php');
}


Destroy session:

session_destroy();

Create array

An array can store multiple values in one variable..

Below is the example of array in php

$days = array("sun","mon","tue","wed","thur","fri","sat"); //array declaration

we also can declare an array like this

$days[1] = "sun";
$days[2] = "mon";
$days[3] = "tue";

the following example is to print the value in array

echo "Today is:".days[1];

the output is
sun