Your Ad Here

 Navigation
Home
Source code
Tutorials
RSS feeds
Articles
Wordpress plugins
Blog
Books
Software
Downloads
Hosting
manuals
Script directory
Training
Our Links




 Sponsors
 Links
finance products
dvd information
dropshippers
 Downloads
 Misc
Webmaster Resources
Only PHP
ScriptSearch.com
Scripts.com - Get the best scripts NOW!
AndreaPHP Programming

Valid XHTML 1.0 Transitional


Valid CSS!


A currency convertor


A currency convertor

This is a currency convertor which allows a user to get the latest currency conversions from Yahoo . This example will convert 1 British pound to 5 other currencies .

Code:

<?
//our currencies
$currency = array("Yen","US Dollars","German mark","french franc","Australian dollar");
//the various URLS for the currency conversions
$conv[0]=file('http://quote.yahoo.com/m5?a=1&s=GBP&t=JPY&c=0');
$conv[1]=file('http://quote.yahoo.com/m5?a=1&s=GBP&t=USD&c=0');
$conv[2]=file('http://quote.yahoo.com/m5?a=1&s=GBP&t=DEM&c=0');
$conv[3]=file('http://quote.yahoo.com/m5?a=1&s=GBP&t=FRF&c=0');
$conv[4]=file('http://quote.yahoo.com/m5?a=1&s=GBP&t=AUD&c=0');
//loop through results
for($i=0; $i<sizeof($conv); $i++)
{
$conv[$i] = join("",$conv[$i]);
//parse out the relevant information
$conv[$i] = ereg_replace(".*<table border=1 cellpadding=2 cellspacing=0>",'',$conv[$i]);
$conv[$i] = ereg_replace("</table>.*",'',$conv[$i]);
$conv[$i] = ereg_replace("</b>.*",'',$conv[$i]);
$conv[$i] = ereg_replace(".*<b>",'',$conv[$i]);
//display results
echo "1 Pound(£) = ".$conv[$i]." ".$currency[$i]."<br>\n";
}
?>

Example :

 

1 Pound(£) = Currency Converter - Yahoo! Finance

Currencies Center

Convert

Please note: The exchange rates given are 'bank rates'. High street rates may be subject to commission

Sponsored Links

Buy Stocks for $4
No Account or Investment Minimums. No Inactivity Fees. Start Today.
www.ShareBuilder.com
stock markets investing
Trade stocks with optionsXpress. Free tools to help with your trade
optionsXpress.com
Free Penny Stock Alerts
Get exclusive penny stock alerts set to move up big. Sign up today.
PennyStockAlley.com
50% to 90% Off Orlando Coupons
Amazing Daily Deals for Restaurants, Spas, Events & more.
LivingSocial.com/Orlando-Coupon
Discovery Academy
Local Experts. Professional Service 319 S Lakewood Dr Orlando FL
QuickLocal.com
Local Police Departments
Find Local Listings for Police Department & DMV in Orlando.
yellowpages.com
Yen
1 Pound(£) = Currency Converter - Yahoo! Finance

Currencies Center

Convert

Please note: The exchange rates given are 'bank rates'. High street rates may be subject to commission

Sponsored Links

$87 Million stock market Winner
California Option Trader Makes $87 Million in stock market in 1 Year.
www.virtualinvestingclub.com
Money Market Mutual Funds
Search Current Yields from Banks and Mutual Fund Companies.
www.BankRate.com
finance investing stock market
Trade stocks with optionsXpress. Free tools to help with your trade
optionsXpress.com
Where is the Stock Market Headed?
The answer may surprise you. Find out now with Chart of the Day.
www.chartoftheday.com
Orlando Real Estate Agent
Orlando Real Estate buyer's agent will find your perfect home.
www.Orlando-BuyersAgent.com
Invest in Orlando Florida
With one of the fastest growing job markets in the US and a population that is growing at double digit rates, the Orlando Real Estate market is poised for large gains in the years to come.
www.florida-realestate-invest.com
US Dollars
1 Pound(£) = Currency Converter - Yahoo! Finance

Currencies Center

Convert

Please note: The exchange rates given are 'bank rates'. High street rates may be subject to commission

Sponsored Links

$87 Million stock market Winner
California Option Trader Makes $87 Million in stock market in 1 Year.
www.virtualinvestingclub.com
Money Market Mutual Funds
Search Current Yields from Banks and Mutual Fund Companies.
www.BankRate.com
finance investing stock market
Trade stocks with optionsXpress. Free tools to help with your trade
optionsXpress.com
Where is the Stock Market Headed?
The answer may surprise you. Find out now with Chart of the Day.
www.chartoftheday.com
Orlando Real Estate Agent
Orlando Real Estate buyer's agent will find your perfect home.
www.Orlando-BuyersAgent.com
Invest in Orlando Florida
With one of the fastest growing job markets in the US and a population that is growing at double digit rates, the Orlando Real Estate market is poised for large gains in the years to come.
www.florida-realestate-invest.com
German mark
1 Pound(£) = Currency Converter - Yahoo! Finance

Currencies Center

Convert

Please note: The exchange rates given are 'bank rates'. High street rates may be subject to commission

Sponsored Links

Buy Stocks for $4
No Account or Investment Minimums. No Inactivity Fees. Start Today.
www.ShareBuilder.com
stock markets investing
Trade stocks with optionsXpress. Free tools to help with your trade
optionsXpress.com
Free Penny Stock Alerts
Get exclusive penny stock alerts set to move up big. Sign up today.
PennyStockAlley.com
50% to 90% Off Orlando Coupons
Amazing Daily Deals for Restaurants, Spas, Events & more.
LivingSocial.com/Orlando-Coupon
Discovery Academy
Local Experts. Professional Service 319 S Lakewood Dr Orlando FL
QuickLocal.com
Local Police Departments
Find Local Listings for Police Department & DMV in Orlando.
yellowpages.com
french franc
1 Pound(£) = Currency Converter - Yahoo! Finance

Currencies Center

Convert

Please note: The exchange rates given are 'bank rates'. High street rates may be subject to commission

Sponsored Links

Buy Stocks for $4
No Account or Investment Minimums. No Inactivity Fees. Start Today.
www.ShareBuilder.com
stock markets investing
Trade stocks with optionsXpress. Free tools to help with your trade
optionsXpress.com
Free Penny Stock Alerts
Get exclusive penny stock alerts set to move up big. Sign up today.
PennyStockAlley.com
50% to 90% Off Orlando Coupons
Amazing Daily Deals for Restaurants, Spas, Events & more.
LivingSocial.com/Orlando-Coupon
Discovery Academy
Local Experts. Professional Service 319 S Lakewood Dr Orlando FL
QuickLocal.com
Local Police Departments
Find Local Listings for Police Department & DMV in Orlando.
yellowpages.com
Australian dollar


 




Books
 Sponsors
 Random Code
soccer news from yahoo(xml)
Turn off Post Revisions(Wordpress)
create a jpeg(image)
 Random Article

So, you have a submission form on your website and need to prevent spam by auto-submitters. The most common way to do this is to implement CAPTCHA - an image with randomly generated string (quote from Wikipedia, free online enciclopedia: “A CAPTCHA is a type of challenge-response test used in computing to determine whether the user is human. "CAPTCHA" is an acronym for "Completely Automated Public Turing test to tell Computers and Humans Apart", trademarked by Carnegie Mellon University.”)

Simple, quick and efficient PHP solution for implement CAPTCHA:

the advantage of this solution: it is easy to read symbols by human and automated captcha processor software, but hard to process the image by computer because common CAPTCHA processors can't understand which one of the outputted symbols it must ignore!

obviously you need PHP engine enabled for your webserver, for execute PHP scripts, and GD (PHP graphics library) for generate the image. Webserver, PHP and GD versions are no matter, the solution below is tested for Apache(Windows and Unix), IIS(Windows), PHP-4, PHP-5, GD, GD2

1) Make a PHP script (separate file captcha.php) which will generate the CAPTCHA image:
[?php
session_start();
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
function _generateRandom($length=6){
$_rand_src = array(
array(48,57) //digits
, array(97,122) //lowercase chars
// , array(65,90) //uppercase chars
);
srand ((double) microtime() * 1000000);
$random_string = "";
for($i=0;$i<$length;$i++){
$i1=rand(0,sizeof($_rand_src)-1);
$random_string .= chr(rand($_rand_src[$i1][0],$_rand_src[$i1][1]));
}
return $random_string;
}
$im = @imagecreatefromjpeg("captcha.jpg");
$rand = _generateRandom(3);
$_SESSION['captcha'] = $rand;
ImageString($im, 5, 2, 2, $rand[0]." ".$rand[1]." ".$rand[2]." ", ImageColorAllocate ($im, 0, 0, 0));
$rand = _generateRandom(3);
ImageString($im, 5, 2, 2, " ".$rand[0]." ".$rand[1]." ".$rand[2], ImageColorAllocate ($im, 255, 0, 0));
Header ('Content-type: image/jpeg');
imagejpeg($im,NULL,100);
ImageDestroy($im);
?]

2) Add the following line at the top of the page where you need to implement the CAPTCHA (there should not be any output before this line, except you use php functions ob_start() and ob_end_flush() to turn on output buffering):
[?php session_start(); ?]

3) Add the following line for check is CAPTCHA entered by visitor valid, before the line where you will proceed submitted message:
[?php if($_SESSION["captcha"]==$_POST["captcha"])
{
//CAPTHCA is valid; proceed the message: save to database, send by e-mail ...
echo 'CAPTHCA is valid; proceed the message';
}
else {

echo 'CAPTHCA is not valid; ignore submission'; }?]

4) Finaly add the CAPTCHA to the form:
[img src="captcha.php" alt="captcha image"][input type="text" name="captcha" size="3" maxlength="3"]

P.S.
notice:
- the tags "[?" and "?]" in code samples above should be replaced to the "", you may download original article and code sample here: free download php captcha demo

- requirements: a webserver (windows or linux no matter) with PHP engine, with GD (graphic library) support, you may check your php settings with phpinfo() function

- you need some blank jpg image for use it as background for CAPTCHA string

By Andrew Ivanov
Site Personalization With PHP
  Network
Programming resources
Tutorials directory
Hosting resources
ASP site
Domain names
Progged
Maxi directory
bigarticle : free articles
A Code
Code N Tutorials




beginners PHP Copyright © 2004 onwards by beginnersPHP.