<?
ob_start();session_start();
include("include/db.inc.php");
include("include/bit_functions.inc.php");
include("include/banner_inc.php");
$db1=new db;

if($_SESSION['lang']==''){
	$_SESSION['lang'] = "en";
}
include('languages/lang_common_'.$_SESSION['lang'].'.php');
include ('languages/lang_user_address_'.$_SESSION['lang'].'.php');

$db1->open();mysql_query("SET NAMES 'utf8'");
$uid=$_SESSION['uid'];
check_login();

 if(isset($_POST['submit'] )){
	$sql_add="insert into t123go_useradd set uid='".$uid."',address='".$_POST['address_type']."',name='".$_POST['name']."',
	additional='".$_POST['additinal']."',street='".$_POST['additinal1']."',city='".$_POST['city']."',postcode='".$_POST['zip']."',
	country='".$_POST['country']."',phone_number='".$_POST['phone']."',submit_date=CURDATE()";
	$myrwd=mysql_query($sql_add);
	header("location:"._BASEURL_."/useraddresses/index.html");
	exit;
 }

if($_POST['update']){
	$sql_update="update t123go_useradd set name='".$_POST['name']."',additional='".$_POST['additinal']."',country='".$_POST['country']."',
	street='".$_POST['additinal1']."',city='".$_POST['city']."',postcode='".$_POST['zip']."',phone_number='".$_POST['phone']."',submit_date=CURDATE()
	where uid='$uid' and address='".$_POST['address_type']."'";
	$update_query=mysql_query($sql_update);
	header("location:"._BASEURL_."/useraddresses/index.html");
exit;
}


if(isset($_POST['submit1'] )){
	$sql_add="insert into t123go_useradd set uid='".$uid."',address='".$_POST['address_type1']."',name='".$_POST['name1']."',
	additional='".$_POST['additinal1']."',street='".$_POST['additinal11']."',city='".$_POST['city1']."',postcode='".$_POST['zip1']."',
	country='".$_POST['country1']."',phone_number='".$_POST['phone1']."',submit_date=CURDATE()";
	$myrwd=mysql_query($sql_add);
	header("location:"._BASEURL_."/useraddresses/index.html");
	exit;
}

if($_POST['update1']){
	$sql_update="update t123go_useradd set name='".$_POST['name1']."',additional='".$_POST['additinal1']."',country='".$_POST['country1']."',
	street='".$_POST['additinal11']."',city='".$_POST['city1']."',postcode='".$_POST['zip1']."',phone_number='".$_POST['phone1']."',submit_date=CURDATE()
	where uid='$uid' and address='".$_POST['address_type1']."'";
	$update_query=mysql_query($sql_update);
	header("location:"._BASEURL_."/useraddresses/index.html");
	exit;

}

?>
<!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>
<base href="<?=_BASEURL_?>/" />
<meta content="<?=_TITLE1_?> offers bargain auctions of new brand products. Save up to 70% for every product almost. Bid and Win high quality products.<?=_TITLE1_?> offers amazing bargains." />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="author" content="Info-Tech Ltd. | We simplify web 2.0"/>
<title>
<?=_TITLE_?>
My Details</title>
<link href="<?=_BASEURLCSSNEW_?>/index.css" rel="stylesheet" type="text/css" />
<link href="<?=_BASEURLCSSNEW_?>/index_sec.css" rel="stylesheet" type="text/css" />
<link href="<?=_BASEURLCSSNEW_?>/personal_acc.css" rel="stylesheet" type="text/css" />
<link href="<?=_BASEURLCSSNEW_?>/user_add.css" rel="stylesheet" type="text/css" />
<!--[if lte IE 6]><style type="text/css" media="screen">/* <![CDATA[ */ @import url(<?=_BASEURLCSSNEW_?>/ie6.css?0:102290); /* ]]> */</style><![endif]-->
<!--[if gte IE 7]><style type="text/css" media="screen">/* <![CDATA[ */ @import url(<?=_BASEURLCSSNEW_?>/ie7.css?0:99961); /* ]]> */</style><![endif]-->
<script type="text/javascript" language="javascript">
function hidedisplay(which){
if (!document.getElementById)
return
if (which.style.display=="block")
which.style.display="none"
else
which.style.display="block"
}
</script>
<script type="text/javascript" language="javascript">
function validate()
{
   
   if(document.regfrm.name.value=='')
	{
		 alert("Enter your Name");
		 document.regfrm.name.focus();
		return false;

	} 
  
	if(document.regfrm.country.value==0)
	{
		 alert("Select your Country");
		 document.regfrm.country.focus();
		return false;

	} 
	 if(document.regfrm.additinal.value=='')
	{
		 alert("Enter your Address");
		 document.regfrm.additinal.focus();
		return false;

	} 
	
	 if(document.regfrm.additinal1.value=='')
	{
		 alert("Enter your Address");
		 document.regfrm.additinal1.focus();
		return false;

	} 
	  if(document.regfrm.zip.value=='')
	{
		 alert("Enter your Zip Code");
		 document.regfrm.zip.focus();
		return false;

	} 
	  if(document.regfrm.phone.value=='')
	{
		 alert("Enter your Phone Number");
		 document.regfrm.phone.focus();
		return false;

	}
	
	 if(document.regfrm.city.value=='')
	{
		 alert("Enter your City Name");
		 document.regfrm.city.focus();
		return false;

	}
	 
	  return true;
}
	
	function validate1()
{

    if(document.regfrm1.name1.value=='')
	{
		 alert("Enter your Name");
		 document.regfrm1.name1.focus();
		return false;

	}
	
	if(document.regfrm1.country1.value==0)
	{
		 alert("Select your Country");
		 document.regfrm1.country1.focus();
		return false;

	} 
	
	if(document.regfrm1.additinal1.value=='')
	{
		 alert("Enter your Address");
		 document.regfrm1.additinal1.focus();
		return false;

	} 
	
	 if(document.regfrm1.additinal11.value=='')
	{
		 alert("Enter your Address");
		 document.regfrm1.additinal11.focus();
		return false;

	} 
	  if(document.regfrm1.zip1.value=='')
	{
		 alert("Enter your Zip Code");
		 document.regfrm1.zip1.focus();
		return false;

	} 
	  if(document.regfrm1.phone1.value=='')
	{
		 alert("Enter your Phone Number");
		 document.regfrm1.phone1.focus();
		return false;

	}
	
	 if(document.regfrm1.city1.value=='')
	{
		 alert("Enter your City Name");
		 document.regfrm1.city1.focus();
		return false;

	}
	 
	
		  return true;
}
	

	
</script>
</head>
<body>
<div id="container">
  <? include("header.php");?>
  <div id="accountleft_bar">
    <? include("view.php");?>
  </div>
  <div id="accountright_bar">
    <div id="use_add">
      <div class="buygreen1" >
        <div class="buygreen2"><div>My Profile</div></div>
        <div class="buygreen3"></div>
      </div>
      <div class="allm100px">
        <div class="allm5px">
          <div id="main_blue_screen">
            <div class="problue">
              <div class="probluemid"><div>Billing Address</div></div>
              <div class="probel"></div>
            </div>
            <?
                $sql_qry=mysql_query("select * from t123go_useradd where uid='$uid' and address='1'");
				$mychk=mysql_fetch_array($sql_qry);
				$billing=mysql_num_rows($sql_qry);
			   ?>
            <form name="regfrm" method="post" action="" onSubmit="return validate();">
              <table width="100%" cellpadding="2" cellspacing="0" border="0">
                <tr>
                  <td colspan="4" align="center" width="146"><input name="address_type" value="1" type="hidden">
                  </td>
                </tr>
                <tr>
                  <td align="left" valign="top">
                    <?=_NAME_;?>
                    :</td>
                  <td align="left" valign="top"><input type="text" name="name" value="<?=$mychk['name'];?>" class="inputtext">
                    *</td>
                  <td align="left" valign="top">
                    <?=_COUNTRY_;?>
                    :</td>
                  <td align="left" valign="top"><select name="country">
                      <option value="0">
                      <?=_SELECT_COUNTRY_;?>
                      </option>
                      <? $country=mysql_query("select * from country");
					while($row_c=mysql_fetch_array($country))
					{
					if($mychk['country']==$row_c['state']){
							?>
                      <option value="<?=$row_c['state'];?>" selected="selected">
                      <?=$row_c['state'];?>
                      </option>
                      <?	}else{?>
                      <option value="<?=$row_c['state'];?>" >
                      <?=$row_c['state'];?>
                      </option>
                      <? }}?>
                    </select></td>
                </tr>
                <tr>
                  <td align="left" valign="top">
                    <?=_ADDRESS_LINE1_;?>
                    :</td>
                  <td align="left" valign="top"><input name="additinal" value="<?=$mychk['additional'];?>" type="text" class="inputtext">
                    *</td>
                  <td align="left" valign="top">
                    <?=_POSTCODE_;?>
                    :</td>
                  <td align="left" valign="top"><input name="zip" value="<?=$mychk['postcode'];?>" type="text" class="inputtext" />
                    *</td>
                </tr>
                <tr>
                  <td align="left" valign="top">
                    <?=_ADDRESS_LINE2_;?>
                    :</td>
                  <td align="left" valign="top"><input name="additinal1" value="<?=$mychk['street'];?>" type="text" class="inputtext">
                    *</td>
                  <td align="left" valign="top">
                    <?=_PHONE_NUMBER_;?>
                    :</td>
                  <td align="left" valign="top"><input name="phone" value="<?=$mychk['phone_number'];?>" type="text" class="inputtext" />
                    *</td>
                </tr>
                <tr>
                  <td align="left" valign="top">
                    <?=_TOWN_CITY_;?>
                    :</td>
                  <td align="left" valign="top"><input name="city" value="<?=$mychk['city'];?>" type="text" class="inputtext">
                    *</td>
                  <td align="left" valign="top">&nbsp;</td>
                  <td align="left" valign="top">&nbsp;</td>
                </tr>
                <tr>
                  <td colspan="4" align="left" valign="top">*
                   <span><?=_MANDATORY_FIELDS_;?></span></td>
                </tr>
                <tr>
                  <td height="50" colspan="4" align="left" valign="top"><div class="tac">
                      <? if($billing){?>
                      <input  type="submit" name="update" class="inputsubmitbig" value=" "  />
                      <? }else{?>
                      <input  type="submit"  name="submit" class="inputsubmitbig" value=" "  />
                      <? }?>
                    </div></td>
                </tr>
              </table>
            </form>
            <div class="tf1">
              <div class="tf2"></div>
              <div class="tf3"></div>
            </div>
          </div>
          <div class="clb tm20px">
            <div id="main_blue_screen">
              <div class="problue">
                <div class="probluemid"><div>Delievery Address</div></div>
                <div class="probel"></div>
              </div>
              <?
                $sql_qry=mysql_query("select * from t123go_useradd where uid='$uid' and address='1'");
				$mychk=mysql_fetch_array($sql_qry);
				$billing=mysql_num_rows($sql_qry);
			   ?>
              <?
              $sql_qry1=mysql_query("select * from t123go_useradd where uid='$uid'and address='2'");
				$mychk1=mysql_fetch_array($sql_qry1);
				$delivery=mysql_num_rows($sql_qry1);
			   ?>
              <form name="regfrm1" method="post" action="" onSubmit="return validate1();">
                <table width="100%" cellpadding="2" cellspacing="0" border="0">
                  <tbody>
                    <tr>
                      <td colspan="4" align="center" width="146"><input name="address_type1" value="2" type="hidden">
                      </td>
                    </tr>
                    <tr>
                      <td align="left" valign="top">&nbsp;</td>
                      <td align="left" valign="top">&nbsp;</td>
                      <td align="left" valign="top">&nbsp;</td>
                      <td align="left" valign="top">&nbsp;</td>
                    </tr>
                    <tr>
                      <td align="left" valign="top">
                        <?=_NAME_;?>
                        :</td>
                      <td align="left" valign="top"><input name="name1" value="<?=$mychk1['name'];?>" type="text" class="inputtext">
                        *</td>
                      <td align="left" valign="top">
                        <?=_COUNTRY_;?>
                        :</td>
                      <td align="left" valign="top"><select name="country1">
                          <option value="0">
                          <?=_SELECT_COUNTRY_;?>
                          </option>
                          <? $country=mysql_query("select * from country");
					while($row_c1=mysql_fetch_array($country))
					{
						if($mychk1['country']==$row_c1['state']){?>
                          <option value="<?=$row_c1['state'];?>" selected="selected">
                          <?=$row_c1['state'];?>
                          </option>
                          <?		}else{?>
                          <option value="<?=$row_c1['state'];?>" >
                          <?=$row_c1['state'];?>
                          </option>
                          <?  	}

			        }
			    ?>
                        </select>
                      </td>
                    </tr>
                    <tr>
                      <td align="left" valign="top">
                        <?=_ADDRESS_LINE1_;?>
                        :</td>
                      <td align="left" valign="top"><input name="additinal1" value="<?=$mychk1['additional'];?>" type="text" class="inputtext">
                        *</td>
                      <td align="left" valign="top">
                        <?=_POSTCODE_;?>
                        :</td>
                      <td align="left" valign="top"><input name="zip1" value="<?=$mychk1['postcode'];?>" type="text" class="inputtext">
                        *</td>
                    </tr>
                    <tr>
                      <td align="left" valign="top">
                        <?=_ADDRESS_LINE2_;?>
                        :</td>
                      <td align="left" valign="top"><input name="additinal11" value="<?=$mychk1['street'];?>" type="text" class="inputtext">
                        * </td>
                      <td align="left" valign="top">
                        <?=_PHONE_NUMBER_;?>
                        :</td>
                      <td align="left" valign="top"><input name="phone1" value="<?=$mychk1['phone_number'];?>" type="text" class="inputtext">
                        *</td>
                    </tr>
                    <tr>
                      <td align="left" valign="top">
                        <?=_TOWN_CITY_;?>
                        :</td>
                      <td align="left" valign="top"><input name="city1" value="<?=$mychk1['city'];?>" type="text" class="inputtext">
                        *</td>
                    </tr>
                    <tr>
                      <td colspan="2" align="left" valign="top"></td>
                    </tr>
                    <tr>
                      <td colspan="2" align="left" valign="top">*
                        <span><?=_MANDATORY_FIELDS_;?></span></td>
                    </tr>
                    <tr>
                      <td height="50" colspan="4" align="left" valign="top"><div class="tac">
                          <? if($delivery){?>
                          <input  type="submit"  name="update1" class="inputsubmitbig" value=" "  />
                        </div>
                        <? }else{?>
                        <input  type="submit" name="submit1" class="inputsubmitbig" value=" "  />
                        <? }?>
                      </td>
                    </tr>
                  </tbody>
                </table>
              </form>
              <div class="tf1">
                <div class="tf2"></div>
                <div class="tf3"></div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="tft1">
        <div class="tft2"></div>
        <div class="tft3"></div>
      </div>
    </div>
  
       
<div  class="w99">
<h3 class="tac tm40px"><div class="tm40px tac"><br /><br /><br /><br /><br />Advertisment Sponsors</div></h3>

  <? 
  $page='innerpage';
  $query_num=mysql_query("select bid from zb_banners where `status`='1' and pagename='$page' order by rand() limit 0,4");
 while($brow=mysql_fetch_array($query_num))
  {
  ?>
<?=banner_home("innerpage","bottom",158,103,$brow['bid']);?>
<? }?>
</div>
</div>
  <div style="clear:both">
    <? include("footer.php");?>

