www.pickatutorial.com Computer Tutorials

PHP HTTP Functions. Free online PHP and MySQL Web Database Programming Tutorial...

Top Tutorials: C/C++ | C#.NET | PHP MySQL | Java | Java Script | jQuery | HTML | xHTML | HTML5 | VB Script
Lessons PHP HTTP Functions Bookmark and Share
Lesson 1
Lesson 2
Lesson 3
Lesson 4
Lesson 5
Lesson 6
Lesson 7
Lesson 8
Lesson 9
Lesson 10
Lesson 11
Lesson 12
Lesson 13
Lesson 14
Lesson 15
Lesson 16
Lesson 17
Lesson 18
Lesson 19
Lesson 20
Lesson 21
Lesson 22
Lesson 23
Lesson 24
Lesson 25
Lesson 26
Lesson 27
Lesson 28
Lesson 29
Lesson 30
Lesson 31
Lesson 32
Lesson 33
Lesson 34
Lesson 35
Lesson 36
Lesson 37
Lesson 38
Lesson 39
Lesson 40
Lesson 41
Lesson 42
Lesson 43
Lesson 44
The header() function is used to output an HTTP header string, such as a URL redirection. The header() function has to be used before any data is sent to the browser, this also includes HTML tags. Failing to do so would result in an error. However, we can do any sort of computations or database manipulations before using this function. The following call to the header() function redirects a user to http://pickatutorial.com.

For example, to use the header() function to redirect a user to a new location, use header("Location: http://www.pickatutorial.com");

Please note the use of the exit command after a call to the header() function. This guarantees that the script stops executing immediately as it reaches the exit command.

This function is used to send a cookie to the user. All the cookies have to be sent to the user before any other data is sent to the user this also included calls to the header() function. Its syntax follows:

setcookie("name", "value");

The PHP mail() function is used to send emails. Its syntax follows:

mail("recipient", "subject", "message", "mail headers");

For example, the following code sends mail to test@mytestemail.com, with a subject of "Test email" and a message body saying "This is a test email message". The From line is part of the additional mail headers.

mail("test@mytestemail.com", "Test email!",
"This is a test email message", "From: myemail@myowndomain.com\n");

Home - Advertise - Contact - Disclaimer - About Us
© Since 2006 pickatutorial.com -- All Rights Reserved.