Location: PHPKode > projects > phpMyPrepaid > phpmyprepaid/www/include/location/add_location_form.php
<?php
/* This file presents the add locations form.
 * C. Carl H Peterson 2005
 * C. Port Networks LLC 2005
 */
if (isset($_POST['location_name']) )
	$location=$_POST['location_name'];
else if (isset($_GET['location_name']) )
	$location=$_GET['location_name'];

include_once('include/divers/functions.php');	
if (isset($reg_error)) { 
	echo('There was an error: $reg_error, please try again.');
}

echo '
<form action="phpmyprepaid.php "method="post">
<input type="hidden" name="buttonID" value="add_loc_process">
<table border="1">
<tr>
        <td colspan="3" align="center"><b>Add a new Location</b></td>
</tr>
<tr>
<td colspan="2" align="right">';
	echo '<b>Location Name:</b> <input type="text" size="15" maxlength="15" name="location" value=\''.$location.'\'>';
echo'	</td>
	<td>
	</td>
</tr>
<tr>
	<td colspan="2" align="right">';
if (isset($_GET['domain']))
	echo '<b>Domain:</b> <input type="text" size="15" maxlength="40" name="domain" value=\''.$_GET['domain'].'\'>';
else
	echo '<b>Domain:</b> <input type="text" size="15" maxlength="40" name="domain">';
echo '
	</td>
</tr>';
$val="";
if (isset($_GET['isocode'])) {
	$country=$_GET['isocode'];
	$query="select iso_code from isocode where iso_name='".$country."'";
	$result=$oreon->database->database->query($query) or die("Query database error !");
	$row = $oreon->database->database->fetch_object($result);
	$val=$row->iso_code;
}

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=addLoc&&areacode="+formulaire.areacode.value+"&&isocode="+formulaire.isoname.value+"&&location_name="+formulaire.location.value+"&&domain="+formulaire.domain.value+"&&city="+formulaire.city.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'];
	$query="select area_code,area_name from areacode where area_short_name='".$country."'";
	$result=$oreon->database->database->query($query) or die("Query database error !");
	$row = $oreon->database->database->fetch_object($result);
	$val2=$row->area_code;
	$val3=$row->area_name;
}

echo '<tr>
	<td colspan="2" align="right">
	<b>Area  code:</b> <input type="text" size="3" maxlength="3" name="area_code" value="'.$val2.'">
	</td>
        <script type="text/javascript"><!--
	function ChangeAreaCode(formulaire){
	if (formulaire.areacode.selectedIndex != 0) {
		document.location.href="phpmyprepaid.php?buttonID=addLoc&&areacode="+formulaire.areacode.value+"&&isocode="+formulaire.isoname.value+"&&location_name="+formulaire.location.value+"&&domain="+formulaire.domain.value+"&&city="+formulaire.city.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">';
if (isset($_GET['city']))
	echo '<b>City:</b> <input type="text" size="15" maxlength="15" name="city" value=\''.$_GET['city'].'\'>';
else
	echo '<b>City:</b> <input type="text" size="15" maxlength="15" name="city" >';


echo '	</td>
	</tr>';
if ($oreon->user->get_status()=="3")
{
echo '<tr>
	<td>
	<input type="submit" name="submit" class="smallButton" value="Add Location">
	</td>';
}
echo '</tr>
</table>
</form>';
?>	
Return current item: phpMyPrepaid