Crap, accidentally put this in the wrong forum. Will a mod please move this to Server Side Programming? Thanks!
I’m testing a class/sql library i found for parsing zip codes and returning info about them.
Here’s my code:
getinfo.php
<?php
require_once('zipcode.class.php'); // zip code class
mysql_pconnect('localhost','root','steel49') or die(mysql_error());
mysql_select_db('zip_db') or die(mysql_error());
$z = new zipcode_class;
function safehtml($s)
{
$s=str_replace("&", "&", $s);
$s=str_replace("<", "<", $s);
$s=str_replace(">", ">", $s);
$s=str_replace("'", "'", $s);
$s=str_replace("\"", """, $s);
return $s;
}
$zipCode = safehtml($_POST["zipcd"]);
echo safehtml($_POST["zipcd"]);
$details = $z->get_zip_details($zipCode);
if (empty($details)) echo 'Error: '.$z->last_error;
else {
foreach ($details as $key => $value) {
$key = str_replace('_',' ',$key);
$key = ucwords($key);
echo "$key: $value<br>";
}
}
?>
**index.html
**
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script src="pageax.js" type="text/javascript"></script>
<style type="text/css">
body {
padding: 20px;
margin: 0;
font-family: Arial, sans-serif;
font-size: 10pt;
}
</style>
</head>
<body>
<p><strong>Get Info About a ZIP Code:</strong><br />
<form action="javascript:gotoPage('getinfo.php')" method="post">
<input type="text" name="zipcd" /><br />
<input type="submit" />
</form>
</p>
<p><div id="content"></div></p>
</body>
</html>
Everything works fine(loads getinfo.php into the div and returns correctly), BUT…
I’ve been able to narrow the problem down to the use of $_POST to pass in the zip code, as I get an error unless I set the ZIP manually in getinfo.php. EX: I get it working correctly using:
$zipCode = "97501";
Instead of:
$zipCode = safehtml($_POST["zipcd"]);
So, I’m assuming that PageAX just dropping(or not even sending) the $_POST info and is returning the error because $zipCode doesn’t contain any info.
Any ideas on how to solve my little problem?
Thanks a whole bunch and high five in advance!