Posts Tagged ‘php header()’

PHP – Redirect to previous page

July 25, 2011 9 comments

If you wish to redirect your users back to the page they were on previously, then you need to issue the following command:

header( 'refresh: 10; url='.$ref);

The refresh indicates the time in seconds between being on the current page and redirecting them back to the previous page.


PHP – Dynamic CSS Error – Stylesheet was not loaded because its MIME type…

July 22, 2011 3 comments

When creating a dynamic css stylesheet you need to remember to include the header() to tell the stylesheet that it is of type text/css. If you do not include this then even if you include text/css in the stylesheet link, Firefox and other browsers will still assume the type is of text/html. If this occurs you will see the following from within Firefox’s error console. (Located under Tools > Error Console):

Error: The stylesheet http://localhost/ukshopdesign/inc/default.css.php was not loaded because its MIME type, "text/html", is not "text/css".
Source File: http://localhost/ukshopdesign/shopfront.php
Line: 0

To overcome this error place the following at the start of your dynamic css stylesheet:

header('Content-type: text/css');

Further Reading