<?
include 'config.php';
include 'func.php';
head();
aut();
ban();
echo "<div class=\"head\">Личный кабинет | <b>Место жительства</b></div><div class=\"padding\">";   
switch($_GET['act']){
    default:
    
    echo "<div class='login'>Выбрана страна: <b>".$country."</b><br/>";
    echo "Выбран регион: <b>".$region."</b><br/>";
    echo "Выбран город: <b>".$city."</b></div>";

echo '</div><div class="link2"><b>Изменение данных:</b><br/>';
echo '<form action="?act=g1" method="post" name="form">';
echo '<b>Страна:</b><br/>
<select name="strana">';
$result = mysql_query("SELECT * FROM geo_countries");
while($a = mysql_fetch_assoc($result)){

    
echo "<option value=".$a['country_id'].">".$a['country_name']."</option><br/>";
}

echo '</select><br/><input name="submit" type="submit" class="button" value="Далее" /></form>';
break;

case 'g1':
$country = num($_POST['strana']);
$_SESSION['country'] = $country;
$country_info = mysql_fetch_assoc(mysql_query("SELECT * FROM `geo_countries` WHERE `country_id` = '".$country."'"));
echo "<div class='login'>Выбрана страна: <b>".$country_info['country_name']."</b></div>";

echo '</div><div class="link2"><form action="?act=g2" method="post" name="form">';
echo '<b>Регион:</b><br/>
<select name="region">';
$result = mysql_query("SELECT * FROM geo_regions WHERE `cid` = '".$country."'");
while($b = mysql_fetch_assoc($result)){

    
echo "<option value=".$b['region_id'].">".$b['region_name']."</option><br/>";
}

echo '</select><br/><input name="submit" type="submit" class="button" value="Далее" /></form>';
break;

case 'g2':
$region = num($_POST['region']);
$_SESSION['region'] = $region;

$country_info = mysql_fetch_assoc(mysql_query("SELECT * FROM `geo_countries` WHERE `country_id` = '".num($_SESSION['country'])."'"));
$region_info = mysql_fetch_assoc(mysql_query("SELECT * FROM `geo_regions` WHERE `region_id` = '".$region."'"));
echo "<div class='login'>Выбрана страна: <b>".$country_info['country_name']."</b><br/>";
echo "Выбран регион: <b>".$region_info['region_name']."</b>";
echo '</div><div class="link2"><form action="?act=g3" method="post" name="form">';
echo '<b>Регион:</b><br/>
<select name="city">';
$result = mysql_query("SELECT * FROM geo_cities WHERE `rid` = '".$region."'");
while($c = mysql_fetch_assoc($result)){

    
echo "<option value=".$c['city_id'].">".$c['city_name']."</option><br/>";
}

echo '</select><br/><input name="submit" type="submit" class="button" value="Далее" /></form>';
break;

case 'g3':
$city = num($_POST['city']);
$_SESSION['city'] = $city;
$country_info = mysql_fetch_assoc(mysql_query("SELECT * FROM `geo_countries` WHERE `country_id` = '".num($_SESSION['country'])."'"));
$region_info = mysql_fetch_assoc(mysql_query("SELECT * FROM `geo_regions` WHERE `region_id` = '".num($_SESSION['region'])."'"));
$city_info = mysql_fetch_assoc(mysql_query("SELECT * FROM `geo_cities` WHERE `city_id` = '".num($_SESSION['city'])."'"));

echo "<div class='link2'>Выбрана страна: <b>".$country_info['country_name']."</b><br/>";
echo "Выбран регион: <b>".$region_info['region_name']."</b><br/>";
echo "Выбран город: <b>".$city_info['city_name']."</b><br/>";

echo "<a href=\"?act=save\">Сохранить</a></div>";
break;

case 'save':
mysql_query("UPDATE `profile` SET `geo_city` = '".num($_SESSION['city'])."',`geo_region` = '".num($_SESSION['region'])."',`geo_country` = '".num($_SESSION['country'])."' WHERE `id` = '".$id_session."'");

echo rew('myinfo/index.php?mod=osnova');
break;

}
navig();
foot();
?>