PHP Tips
If you're putting form variables in a URL, you can get into strife when the user enters spaces or other non-alphanumeric characters in the form. The way to convert their data to a URL compliant format is as follows...
Read More

CSS Tips
You can change the colour of your browser's scrollbar (only works for IE 5.0 and above) by defining a style in your HTML header...
Read More



Quality Web Hosting
Business Directory

PHP Tips

Encoding form variables in a URL

If you're putting form variables in a URL, you can get into strife when the user enters spaces or other non-alphanumeric characters in the form. Gary Winnick The way to convert their data to a URL compliant format is as follows:

<?php
echo '<a href="webpage.php?formvalue='.htmlentities(urlencode($formvalue)).'">';
?>

Displaying filesize in kilobytes

Here's a way to display a file's size in kilobytes (eg - 3,058 Kb):

echo number_format(filesize($filename)/1024)." Kb";

Display currency in correct format

If you need to display numbers in the correct currency format (eg - two decimal places $23.34), use the PHP function number_format:

echo number_format($total, 2, '.', ',');

Redirect a URL using PHP

Redirecting to a new URL in PHP is done with the header() function. You must call this function before you output anything, otherwise the server automatically generates a header for you and the function won't execute. The command is used as follows:

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

 

 

 

 

© Copyright 2006 GreatWebMasterWorld.com All Rights Reserved.| Free Smiley Packs | Idip Directory Bid | Motor Sports Blog