Archive for May 14th, 2009

PHP Sessions

A PHP session variable is used to store information about, or change settings for a user session. Session variables hold information about one single user, and are available to all pages in one application.

PHP Session Variables
When you are working with an application, you open it, do some changes and then you close [...]

Continue reading »

PHP Cookies

cookie is often used to identify a user.

What is a Cookie?
A cookie is often used to identify a user. A cookie is a small file that the server embeds on the user’s computer. Each time the same computer requests a page with a browser, it will send the cookie too. With PHP, you [...]

Continue reading »

PHP File Upload

With PHP, it is possible to upload files to the server.

Create an Upload-File Form
To allow users to upload files from a form can be very useful.
Look at the following HTML form for uploading files:

<html>
<body>
<form action=”upload_file.php” method=”post”
enctype=”multipart/form-data”>
<label for=”file”>Filename:</label>
<input type=”file” name=”file” id=”file” />
<br />
<input type=”submit” name=”submit” value=”Submit” />
</form>
</body>
</html>

Notice the following about the HTML form above:

The enctype attribute [...]

Continue reading »

PHP File Handling

The fopen() function is used to open files in PHP.

Opening a File
The fopen() function is used to open files in PHP.
The first parameter of this function contains the name of the file to be opened and the second parameter specifies in which mode the file should be opened:

<html>
<body>
<?php
$file=fopen(“welcome.txt”,”r”);
?>
</body>
</html>

The file may be opened in one [...]

Continue reading »

PHP Include File

Server Side Includes (SSI) are used to create functions, headers, footers, or elements that will be reused on multiple pages.

Server Side Includes
You can insert the content of a file into a PHP file before the server executes it, with the include() or require() function. The two functions are identical in every way, [...]

Continue reading »