PHP Questions Home | Register | Login
Categories
Arrays
Files
Forms
Creating PDFs
PHP Errors
Functions
Images
MySQL
Numbers
Others
Strings
Website
Unanswered

PHP Forums
Forums Index
MySQL Forum
PHP Forum
Flash/Actionscript
Javascript
Web design

More PHP
PHP Functions
Top Questions
Ask a Question
PHP Interview Questions
PHP Jobs
Ecommerce
IT Questions
Business Websites

Sponsors

sponsor ad
My Salary
PHP Developer Salary
Advertise Here

How do I send HTTP headers with PHP?


This is done with the header function, another very handy built-in PHP function.

Here is an example of using header to re-direct to a different webpage:

<?php
header
("Location: http://www.php-questions.com");
?>


There are two mistakes that everyone makes with header the first time they use it so since we're feeling nice, we'll tell you up front to stop some head scratching.

First, the header command must be called before anything is sent to the web browser, otherwise a nice error message will occur.

Second, you'll want to stop execution of the script after the header call, so be sure to include exit; directly underneath. We just saved you a whole load of hassle!



Comment on this Question and Answer >>>

ASK A QUESTION

More website PHP Questions

I have two web solutions I downloaded from the internet. Jobs Portal, Classified and a forum script. Each of the scripts has its own signup and log in module. How can I make visitors register and login through one webpage without having to login in all th

How do I perform a 301 redirect with PHP?

Hi, I need to fetch data from a web page with PHP. The only problem that I face is that I need to log in with name and password.

How to run a php script on different browsers?

where do i go to paste my google adsense code?



Custom Search