/ Published in: PHP
                    
                                        
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/
                
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
<?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. //
// ****************************************************** //
}
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
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>
URL: http://www.arnoldb.com/2009/06/17/areacode-lookup-script/
Comments
 Subscribe to comments
                    Subscribe to comments
                
                