php

Sending E-mails

[L]PHP allows you to send e-mails directly from a script. -------------------------------------------------------------------------------- [color=FA0309]The PHP mail() Function[/color] The PHP mail() function is used to send emails from inside a script. [color=FA0309]Syntax[/color] [php]mail(to,subject,message,headers,parameters)[/php] [center][img]http://www.nwahy.com/images/im/mail.jpg[/img][/center] [code][color=FA0309]Note[/color]: For the mail functions to be available, PHP requires an installed and working email system. The program to be used is defined by the configuration settings in ...

  • 20-3-2008
  • 1793

Sessions

[L]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. -------------------------------------------------------------------------------- [color=FA0309]PHP Session Variables[/color] When you are working with an application, you open it, do some changes and then you close it. This is much like a Session. The computer knows who you are. It knows when you start the application and when you end. But on the internet there is one problem: the web ...

  • 20-3-2008
  • 1802

Cookies

[L]A cookie is often used to identify a user. -------------------------------------------------------------------------------- [color=FA0309]What is a Cookie?[/color] 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 can both create and retrieve cookie values. -------------------------------------------------------------------------------- [color=FA0309]How to Create a Cookie?[/color] The setcookie() function is used to set a ...

  • 20-3-2008
  • 1881

File Upload

[L]With PHP, it is possible to upload files to the server. -------------------------------------------------------------------------------- [color=FA0309]Create an Upload-File Form[/color] To allow users to upload files from a form can be very useful. Look at the following HTML form for uploading files: [code] Filename: [/code] [U]Notice the following about the HTML form above:[/U] - The enctype attribute of the tag specifies which content-type to use when submitting the form. "multipart/form-data" is used when a form requires binary data, like the contents of a file, to be ...

  • 20-3-2008
  • 2330

File Handling

[L]The fopen() function is used to open files in PHP. -------------------------------------------------------------------------------- [color=FA0309]Opening a File[/color] 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: [php] [/php] The file may be opened in one of the following modes: [center][img]http://www.nwahy.com/images/im/file.jpg[/img][/center] [code][color=FA0309]Note[/color]: If the fopen() function is unable to open ...

  • 20-3-2008
  • 1738

Include File

[L]Server Side Includes (SSI) are used to create functions, headers, footers, or elements that will be reused on multiple pages. -------------------------------------------------------------------------------- [color=FA0309]Server Side Includes[/color] 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, except how they handle errors. The include() function generates a warning (but the script will continue execution) while the require() function generates a fatal error (and ...

  • 20-3-2008
  • 2596

Date

[L]The PHP date() function is used to format a time or a date. -------------------------------------------------------------------------------- [color=FA0309]The PHP Date() Function[/color] The PHP date() function formats a timestamp to a more readable date and time. [color=FA0309]Syntax[/color] date(format,timestamp) [U]format[/U] : Required. Specifies the format of the timestamp [U]timestamp[/U] : Optional. Specifies a timestamp. Default is the current date and time (as a timestamp) -------------------------------------------------------------------------------- [color=FA0309]PHP Date ...

  • 20-3-2008
  • 1551

$_POST

[L]The $_POST variable is used to collect values from a form with method="post". -------------------------------------------------------------------------------- [color=FA0309]The $_POST Variable[/color] The $_POST variable is an array of variable names and values sent by the HTTP POST method. The $_POST variable is used to collect values from a form with method="post". Information sent from a form with the POST method is invisible to others and has no limits on the amount of information to send. [color=FA0309]Example[/color] [code] Enter your name: Enter your age: [/code] When the ...

  • 20-3-2008
  • 1773

$_GET

[L]The $_GET variable is used to collect values from a form with method="get". -------------------------------------------------------------------------------- [color=940306]The $_GET Variable[/color] The $_GET variable is an array of variable names and values sent by the HTTP GET method. The $_GET variable is used to collect values from a form with method="get". Information sent from a form with the GET method is visible to everyone (it will be displayed in the browser's address bar) and it has limits on the amount of information to send (max. 100 ...

  • 20-3-2008
  • 1833

PHP Forms and User Input

[L]The PHP $_GET and $_POST variables are used to retrieve information from forms, like user input. -------------------------------------------------------------------------------- [color=940306]PHP Form Handling[/color] The most important thing to notice when dealing with HTML forms and PHP is that any form element in an HTML page will automatically be available to your PHP scripts. [color=FA0309]Form example:[/color] [code] Name: Age: [/code] The example HTML page above contains two input fields and a submit button. When the user fills in this form and click on the submit ...

  • 20-3-2008
  • 1890

Functions

[L]The real power of PHP comes from its functions. In PHP - there are more than 700 built-in functions available. -------------------------------------------------------------------------------- [color=940306]PHP Functions[/color] In this tutorial we will show you how to create your own functions. -------------------------------------------------------------------------------- [color=940306]Create a PHP Function[/color] A function is a block of code that can be executed whenever we need it. Creating PHP functions: - All functions start with the word "function()" - Name the function - It ...

  • 20-3-2008
  • 1660

Looping

[L]Looping statements in PHP are used to execute the same block of code a specified number of times. -------------------------------------------------------------------------------- [color=940306]Looping[/color] Very often when you write code, you want the same block of code to run a number of times. You can use looping statements in your code to perform this. In PHP we have the following looping statements: - while - loops through a block of code if and as long as a specified condition is true - do...while - loops through a block of code once, and then repeats the loop as long as a special ...

  • 20-3-2008
  • 1494

PHP Arrays

[L]An array can store one or more values in a single variable name. -------------------------------------------------------------------------------- [color=940306]What is an array?[/color] When working with PHP, sooner or later, you might want to create many similar variables. Instead of having many similar variables, you can store the data as elements in an array. Each element in the array has its own ID so that it can be easily accessed. There are three different kind of arrays: - [B]Numeric array[/B] - An array with a numeric ID key - [B]Associative array[/B] - An array where each ID key ...

  • 20-3-2008
  • 1663

PHP Switch Statement

[L]The Switch statement in PHP is used to perform one of several different actions based on one of several different conditions. -------------------------------------------------------------------------------- [color=940306]The Switch Statement[/color] If you want to select one of many blocks of code to be executed, use the Switch statement. The switch statement is used to avoid long blocks of if..elseif..else code. [color=FA0309]Syntax[/color] [php]switch (expression) { case label1: code to be executed if expression = label1; break; case label2: code to be executed if ...

  • 20-3-2008
  • 1666

PHP If...Else Statements

[L]The if, elseif and else statements in PHP are used to perform different actions based on different conditions. -------------------------------------------------------------------------------- [color=940306]Conditional Statements[/color] Very often when you write code, you want to perform different actions for different decisions. You can use conditional statements in your code to do this. [B]if...else statement [/B]- use this statement if you want to execute a set of code when a condition is true and another if the condition is not true [B]elseif statement [/B]- is used with the ...

  • 20-3-2008
  • 1750

PHP Operators

[L]Operators are used to operate on values. -------------------------------------------------------------------------------- [color=940306]PHP Operators[/color] This section lists the different operators used in PHP. [color=940306]Arithmetic Operators[/color] [center][img]http://www.nwahy.com/images/im/op1.jpg[/img][/center] [color=940306]Assignment Operators[/color] [center][img]http://www.nwahy.com/images/im/op2.jpg[/img][/center] [color=940306]Comparison Operators[/color] [center][img]http://www.nwahy.com/images/im/op3.jpg[/img][/center] [color=940306]Logical ...

  • 20-3-2008
  • 1681