<? ob_start();
session_start();
 include("../include/db.inc.php"); 
  include("../include/bit_functions.inc.php");
   include("../include/mail.php");
   $db1=new db;
   $db1->open();
    mysql_query("SET NAMES 'utf8'");
   if($_SESSION['uname']=='' || $_SESSION['pwd']=='')
		{
			header("location:login.php");
		}

 if(isset($_POST['submit'] )){
$sql_add="insert into t123go_useradd set uid='".$_POST['user_id']."',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:user_list.php");
	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='".$_POST['user_id']."' and address='".$_POST['address_type']."'";
	$update_query=mysql_query($sql_update);
	header("location:user_list.php");
	exit();

}
$user_id=$_GET['user_id'];

?>
 <!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=utf-8" />
<title>Money Auctions | Admin Controls</title>
<link href="index.css" rel="stylesheet" type="text/css" />

</head>
<body >
<div class="admin_wrapper">
<div class="logo_show"><? include("minorlogout.php");?></div>
<div style="float:left; width:200px">
<div class="topg_links_show"><? include("left.php");	?></div>
<div class="top_links_show"><? include("belowleft1.php");	?></div></div>
<div style="float:left; width:800px">
<div class="maximum">
<table border="0" cellpadding="0" cellspacing="0" >
    <tr><td>
    <table border="0" cellpadding="0" cellspacing="0" >
    <tr>
       
      <td style="padding-left:20px; color:#5C5C5C" valign="top">
	  <table width="100%" border="0" cellpadding="0" cellspacing="0" class="bodytxt">
                    <tr>
                      <td width="33" valign="top"><img src="img/03.gif" width="33" height="23"></td>
                      <td background="img/bg01.gif"><strong>&nbsp;ADD/EDIT BILLING ADDRESSES</strong></td>
                      <td width="35"><img src="img/04.gif" width="35" height="23"></td>
                    </tr>
                  </table>
				  <table  width="100%" border="0" cellpadding="0" cellspacing="0" class="bodytxt">
                    <tr>
                      <td width="22" valign="top" background="img/tbl-left04.gif"><img src="img/tbl-left04.gif" width="22" height="13"></td>
                      <td valign="top" align="center">
   
	  <?
                $sql_qry=mysql_query("select * from t123go_useradd where uid='$user_id' and address='1'");
				$mychk=mysql_fetch_array($sql_qry);
				$billing=mysql_num_rows($sql_qry);
			   ?>

	    <form name="regfrm" method="post" action="" >
		<input type="hidden" name="user_id" value="<?=$user_id?>" />
		<input type="hidden" name="address_type" value="1" />
		
          <table border="0" cellpadding="2" cellspacing="0" width="350"  >
            <tbody><tr>
              <td colspan="2" align="center" width="146">
              </td>
            </tr>
			
            <tr>
              <td><strong>Address Type:</strong></td>
              <td>Blling Address</td>
            </tr>
            <tr>
              <td><strong>Name:</strong></td>
              <td><input name="name" value="<?=$mychk['name'];?>" type="text"></td>
            </tr>
            <tr>
              <td><strong>Address 1:</strong></td>
              <td><input name="additinal" value="<?=$mychk['additional'];?>" type="text"></td>
            </tr>
            <tr>
              <td><strong>Address 2:</strong></td>
              <td><input name="additinal1" value="<?=$mychk['street'];?>" type="text"> </td>
            </tr>
            <tr>
              <td><strong>City:</strong></td>
              <td><input name="city" value="<?=$mychk['city'];?>" type="text"></td>
            </tr>
             <tr>
              <td><strong>Country:</strong></td>
              <td>
                <select name="country" style="width:150px;">
				<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><strong>Postal Code:</strong></td>
              <td><input name="zip" value="<?=$mychk['postcode'];?>" type="text"></td>
            </tr>
            <tr>
              <td><strong>Phone Number:</strong></td>
              <td><input name="phone" value="<?=$mychk['phone_number'];?>" type="text"></td>
            </tr>
            <tr>
              <td colspan="2"></td>
            </tr>

           
            <tr>
              <td colspan="2" height="50">
			  <? if($mychk['uid']!='' ){?>
              <input  type="submit" name="update" class="inputsubmit" value="Update"  />
			  <? }else{?>
			  <input  type="submit" name="submit" class="inputsubmit" value="Add"  />
			  <? }?>
            </td>
              </tr>
          </tbody></table>
      </form>
	
    
                      </td>
             <td width="19" valign="top" background="img/tbl-right04.gif"><img src="img/tbl-right04.gif" width="19" height="9"></td>
                    </tr>
                  </table>
                  <table width="100%" border="0" cellpadding="0" cellspacing="0" class="bodytxt">
              <tr> 
                <td width="33"><img src="img/tbl-bot01.gif" width="33" height="12"></td>
                <td  width="709" align="right" background="img/tbl-bg.gif"></td>
                <td width="33"><img src="img/tbl-right05.gif" width="35" height="12"></td>
              </tr>
            </table></td>
				  
	  </tr>
	  </table></td>
	  <td>
	  <table border="0" cellpadding="0" cellspacing="0" >
    <tr>
       
      <td style="padding-left:20px; color:#5C5C5C" valign="top">
	  <table width="100%" border="0" cellpadding="0" cellspacing="0" class="bodytxt">
                    <tr>
                      <td width="33" valign="top"><img src="img/03.gif" width="33" height="23"></td>
                      <td background="img/bg01.gif"><strong>&nbsp;ADD/EDIT DELIVERY ADDRESSES</strong></td>
                      <td width="35"><img src="img/04.gif" width="35" height="23"></td>
                    </tr>
                  </table>
				  <table  width="100%" border="0" cellpadding="0" cellspacing="0" class="bodytxt">
                    <tr>
                      <td width="22" valign="top" background="img/tbl-left04.gif"><img src="img/tbl-left04.gif" width="22" height="13"></td>
                      <td valign="top" align="center">
           
   
	  <?
                $sql_qry=mysql_query("select * from t123go_useradd where uid='$user_id' and address='2'");
				$mychk=mysql_fetch_array($sql_qry);
				$billing=mysql_num_rows($sql_qry);
			   ?>
	 
	    <form name="regfrm1" method="post" action="" >
		<input type="hidden" name="user_id" value="<?=$user_id?>" />
		<input type="hidden" name="address_type" value="2" />
          <table border="0" cellpadding="2" cellspacing="0" width="350"  >
            <tbody><tr>
              <td colspan="2" align="center" width="146">
              </td>
            </tr>
			
            <tr>
              <td><strong>Address Type:</strong></td>
              <td>Delivery Address</td>
            </tr>
            <tr>
              <td><strong>Name:</strong></td>
              <td><input name="name" value="<?=$mychk['name'];?>" type="text"></td>
            </tr>
            <tr>
              <td><strong>Address 1:</strong></td>
              <td><input name="additinal" value="<?=$mychk['additional'];?>" type="text"></td>
            </tr>
            <tr>
              <td><strong>Address 2:</strong></td>
              <td><input name="additinal1" value="<?=$mychk['street'];?>" type="text"> </td>
            </tr>
            <tr>
              <td><strong>City:</strong></td>
              <td><input name="city" value="<?=$mychk['city'];?>" type="text"></td>
            </tr>
             <tr>
              <td><strong>Country:</strong></td>
              <td>
                <select name="country" style="width:150px;">
				<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><strong>Postal Code:</strong></td>
              <td><input name="zip" value="<?=$mychk['postcode'];?>" type="text"></td>
            </tr>
            <tr>
              <td><strong>Phone Number:</strong></td>
              <td><input name="phone" value="<?=$mychk['phone_number'];?>" type="text"></td>
            </tr>
            <tr>
              <td colspan="2"></td>
            </tr>

           
            <tr>
              <td colspan="2" height="50">
			  <? if($mychk['uid']!='' ){?>
              <input  type="submit" name="update" class="inputsubmit" value="Update"  />
			  <? }else{?>
			  <input  type="submit" name="submit" class="inputsubmit" value="Add"  />
			  <? }?>
            </td>
              </tr>
          </tbody></table>
      </form>
	
    
                      </td>
             <td width="19" valign="top" background="img/tbl-right04.gif"><img src="img/tbl-right04.gif" width="19" height="9"></td>
                    </tr>
                  </table>
                  <table width="100%" border="0" cellpadding="0" cellspacing="0" class="bodytxt">
                    <tr>
                      <td width="33"><img src="img/tbl-bot01.gif" width="33" height="12"></td>
                      <td align="right" background="img/tbl-bg.gif"><img src="img/tbl-right05.gif" width="35" height="12"></td>
                    </tr>
                  </table></td>
				  
	  </tr>
	  </table></td></tr></table>
	  </div></div>
<div class="bottom_links_show"><? include("footer.php");	?></div>
</div>
<!--::::::::::::::::::::::::::::::::::::::::::::::::::::::::::footer ends:::::::::::::::::::::::::::::::::::::::::::::::::::::-->
</body>
</html>