Revision: 15997
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at July 22, 2009 13:45 by arnoldb
Initial Code
<?php // ****************************************************** // // areacode.php -- Areacode Lookup Script // // // // Author: Brad Arnold -- http://arnoldb.com // // // // Licensed under Creative Commons - Share Alike // // Licensed under GPL2 // // // // This simple script will take an inputted area code // // and return the state in which the area code belongs. // // // // This file must be named areacode.php and the file // // areacodes.inc.php must reside in the same directory // // unless changes to the code are made. // // ****************************************************** // if(!file_exists("areacodes.inc.php")) { die("ERROR! Areacode Data File is Missing or Corrupt!"); } else { require("areacodes.inc.php"); } ?> <html> <head> <title>Area Code Lookup Utility</title> </head> <body> <!-- Begin Form --> <form action="areacode.php" method="get" onreset="doReset();"> Area Code: <input type="text" name="fareacode" maxlength="3" size="2"/> <input type="submit" /> <button onclick="form.reset();">Reset</button> </form> <!-- Begin code --> <?php // Put GET data into variable for ease of use $input = $_GET["fareacode"]; // Check the variable, if empty show instructions, if in-use show results if ($input) { // If input doesn't match an Area Code in the array return and error if(empty($areacode[$input])) { echo "Sorry," . " " . "<a style=font-weight:bold; />" . $input . "</a>" . " " . "is not a valid Area Code."; } else echo "Area code" . " " . "<a style=font-weight:bold; />" . $input . "</a>" . " " . "is found in the state of:" . " " . "<a style=font-weight:bold; />" . $areacode[$input] . "</a>"; } else echo "Enter a three (3) digit Area Code in the box above."; ?> </body> </html>
Initial URL
http://www.arnoldb.com/2009/06/17/areacode-lookup-script/
Initial Description
This simple script will return what state an areacode belongs to. Be sure to get the include file that contains the array here: http://snipplr.com/view/17340/area-code-lookup-script--include-file/
Initial Title
Area Code Lookup Script
Initial Tags
php
Initial Language
PHP