Location: PHPKode > projects > phpMyPrepaid > phpmyprepaid/www/include/location/modify_location_form.php
<?php
/* This file presents the add locations form.
 * C. Carl H Peterson 2005
 * C. Port Networks LLC 2005
 */
if (isset($reg_error)) { 
	echo('There was an error: $reg_error, please try again.');
}
if (isset($_POST['location_name']) )
	$location=$_POST['location_name'];
else if (isset($_GET['location_name']) )
	$location=$_GET['location_name'];



$query="select LocationDomain,LocationState,LocationCity,LocationCountry from locations where LocationName = '$location'";
$result=$oreon->database->database->query($query);
$row = $oreon->database->database->fetch_object($result);
$loc_city=$row->LocationCity;
$loc_state=$row->LocationState;
$loc_domain=$row->LocationDomain;
$loc_country=$row->LocationCountry;
?>
	
<form action="phpmyprepaid.php "method="post">
<input type="hidden" name="buttonID" value="mod_loc">
<input type="hidden" name="formsubmit" value="true">
<input type="hidden" name="location" value="<?php echo $location?>">
<table border="1">
<tr>
<td colspan="3" align="center"><b>Modify Location name <?php echo $location ?></b></td>
</tr>
<tr>
	<td colspan="2" align="right">
	<b>Domain:</b> <input type="text" size="20" maxlength="40" name="domain" value="<?php echo $loc_domain ?>">
	</td>
</tr>
<?php
$val="";
if (isset($_GET['isocode'])) {
	$country=$_GET['isocode'];
	$query2="select iso_code from isocode where iso_name='".$country."'";
	$result2=$oreon->database->database->query($query2) or die("Query database error !");
	$row2 = $oreon->database->database->fetch_object($result2);
	if ($row2->iso_code!="")
		$val=$row2->iso_code;
	else
		$val=$loc_country;

}
else {
	$val=$loc_country;
	$country='';
}

echo '<tr>
	<td colspan="2" align="right">
	<b>Country code:</b> <input id="country" type="text" size="2" maxlength="2" name="country" value="'.$val.'">
	</td>

        <script type="text/javascript"><!--
function ChangeIsoCountry(formulaire){
	if (formulaire.isoname.selectedIndex != 0) {
		document.location.href="phpmyprepaid.php?buttonID=mod_loc&&areacode="+formulaire.areacode.value+"&&isocode="+formulaire.isoname.value+"&&location_name="+formulaire.location.value; 
	}
};;
// --></script>';

	$query="select iso_name from isocode";
	$result=$oreon->database->database->query($query) or die("Query database error !");
	echo '<td><form action="phpmyprepaid.php" method="post">';
	echo ('<select id="isoname" onchange="ChangeIsoCountry(this.form)">');
	echo ("<option  value=\"\">");
	while ($row = $oreon->database->database->fetch_object($result)) 
	{
		if ($country==$row->iso_name)
			echo ("<option selected=\"selected\" value=\"".$row->iso_name."\">".$row->iso_name);
		else
			echo ("<option  value=\"".$row->iso_name."\">".$row->iso_name);

	}
	echo '</select></td>';
		
?>	
<?php
$val2="";
$val3="";
if (isset($_GET['areacode'])) {
	$country=$_GET['areacode'];
	if ($country!='') {
		$query2="select area_code,area_name from areacode where area_short_name='".$country."'";

		$result2=$oreon->database->database->query($query2) or die("Query database error !");
		$row2 = $oreon->database->database->fetch_object($result2);
		
		if ($row2->area_code!="") 
		{
			$val2=$row2->area_code;
			$val3=$row2->area_name;
		}
		else
			$val2=$loc_state;
           }
}
else
{
	$val2=$loc_state;
}
echo '<tr>
	<td colspan="2" align="right">
	<b>Area  code:</b> <input type="text" size="3" maxlength="3" name="state" value="'.$val2.'">
	</td>
        <script type="text/javascript"><!--
	function ChangeAreaCode(formulaire){
	if (formulaire.areacode.selectedIndex != 0) {
		document.location.href="phpmyprepaid.php?buttonID=mod_loc&&areacode="+formulaire.areacode.value+"&isocode="+formulaire.isoname.value+"&&location_name="+formulaire.location.value;; 
	}
};;
// --></script>';

	$query="select area_short_name from areacode";
	$result=$oreon->database->database->query($query) or die("Query database error !");
	echo '<td>';
	echo ("<select id=\"areacode\" onchange=\"ChangeAreaCode(this.form)\">");
	echo ("<option  value=\"\">");
	while ($row = $oreon->database->database->fetch_object($result)) 
	{
		if ($country==$row->area_short_name)
			echo ("<option selected=\"selected\" value=\"".$row->area_short_name."\">".$row->area_short_name);
		else
			echo ("<option  value=\"".$row->area_short_name."\">".$row->area_short_name);

	}
	echo "</select><small>".substr($val3,0,50)."</small></td></form>";
		
echo '</tr>
<tr>
	<td colspan="2" align="right">
	<b>City:</b> <input type="text" size="15" maxlength="15" name="city" value=\''.$loc_city.'\'>
	</td>
</tr>
<tr>
	<td>
	<input type="submit" class="smallButton" name="submit" value="Modify Location">
	</td>
</tr>
</table>
</form>';
?>
Return current item: phpMyPrepaid