<?php 
require_once 'yanzheng.php';
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"/>
<title>用户中心:天天链接网</title>
<meta name="keywords" content="<?=$site['keywords']?>"/>
<meta name="description" content="<?=$site['miaoshu']?>"/>
<link rel="stylesheet" href="/css/index.css">
<link rel="stylesheet" href="/page.css">
<link rel="stylesheet" href="/css/bootstrap.min.css">
<script src="/js/jquery.js"></script>
<script src="/js/bootstrap.min.js"></script>
<script src="/layer/layer.js"></script>
</head>
 
<body>
<?php 
require_once 'head_user.php';	
?>

<div class="box">   

	
	<!--左边-->
		<div class="zuo">
	
			<?php 
				require_once 'user_left.php';	
			?>
		   
	
		
		</div>
		
	<!--左边-->
	
	
	<?php 
	$id=$_GET['id'];
	$row=query("select * from url_data where id='$id'");
	?>
	
	<!--右边-->
		<div class="you">
		
		<form action="" method="post">
		
			<table width="100%" border="0" cellspacing="0" cellpadding="0" class="biaoge">		 
				  <tr>
					<td width="200">网站名称</td>
					<td><input name="sitename" type="text" style="width:100%"  value="<?=$row['sitename']?>" /></td>
				  </tr>
				 
				 <tr>
					<td width="200">网站URL</td>
					<td><?=$row['url']?></td>
				  </tr>
				  
				  
				 <tr>
					<td>网站类别</td>
					<td>
						<select name="type">			
							<option value="<?=$row[type]?>"><?=$row[type]?></option>			
							<?php		    						
							$arr=listquery("select * from url_type order by id asc");		
							foreach ($arr as $v) {
							 ?>
							 <option value="<?=$v[type]?>"><?=$v[type]?></option>
						   
							   <?php
							   }		  
							   ?>	
					   </select>
					</td>
				  </tr>
				 
				  <tr>
					<td width="200">QQ</td>
					<td><input name="qq" type="text" value="<?=$row['qq']?>" /></td>
				  </tr>
				 
				 <tr>
					<td width="200">微信二维码</td>
					<td>
					    <p><input type="file" id="dataimg"   onChange="put();"/></p>
                    						
						<p><div id="showimg"></div></p>
						
						<p><input name="weixin"  type="hidden"  id="img" value="<?=$row['weixin']?>" /></p>
						
						<script>
						
						  function put(){
									var pan=$("#dataimg").val();
									if(pan==''){
										alert('请选择图片');
										return false;
										}
									
								  
									$("#showimg").html("<font color=red>上传中....请稍候...</font>");
									var formData = new FormData();
									formData.append("uploadfile", document.getElementById("dataimg").files[0]);
									$.ajax({
										url: "uploadok.php",
										type: "POST",
										data: formData,
										/**
										 *必须false才会自动加上正确的Content-Type
										 */
										contentType: false,
										/**
										 * 必须false才会避开jQuery对 formdata 的默认处理
										 * XMLHttpRequest会对 formdata 进行正确的处理
										 */
										processData: false,
										success: function (data) {
										   if(data){
												 $("#dataimg").val(''); //置空初始化数据												
												 var obj = JSON.parse(data); //由JSON字符串转换为JSON对象
										
										         str = obj.content;
												 $("#showimg").html('<font color=red>'+str+'</font>');
											     img = obj.url;
											     $("#img").val(img);
										   }										   									   
											   
										},
										error: function () {
											alert("上传失败！");
											$("#dataimg").val('');
										}
									});
							
							}	
						
						</script>
					
					</td>
				  </tr>
				 
				 
				 
				 <tr>
					<td width="200">交换要求</td>
					<td>
					来者不拒 <input name="yaoqiu" type="radio" value="来者不拒" <?php $yaoqiu=$row['yaoqiu']; if($yaoqiu=='来者不拒'){echo 'checked="checked"';}?>  style="margin-right:20px;" >
					同行相关 <input name="yaoqiu" type="radio" value="同行相关" <?php $yaoqiu=$row['yaoqiu']; if($yaoqiu=='同行相关'){echo 'checked="checked"';}?>  style="margin-right:20px;" >
					</td>
				  </tr>
				  
				   <tr>
					<td></td>
					<td><input name="submit" type="submit" value="修改" class="btn btn-primary" /></td>
				  </tr>
				  
				</table>
				 </form>
				 
				
				 
				 
				<?php 
				
				

				
				if($_POST['submit']){
				
				
				 $sitename=$_POST['sitename'];	
				 $type=$_POST['type'];
				 
				 $qq=$_POST['qq'];					 				
				 $weixin=$_POST['weixin'];
				 
				 $yaoqiu=$_POST['yaoqiu'];
				
				 
				 if(empty($sitename)){
				 msg('请输入网站名称');
				 }
				
				 if(empty($qq)){
				 msg('请输入QQ');
				 }
			
				 $time=date("Y-m-d H:i");
				 
				 $url=str_replace("https://","",$url);
				 $url=str_replace("http://","",$url);
				 
		
				 
				 $arr=array(					
				'sitename'=>$sitename,		
				'type'=>$type,
				'qq'=>$qq,	
				'weixin'=>$weixin,				
				'yaoqiu'=>$yaoqiu
				);
				
				$sql=upsql($arr);		 
				mysql_query("update url_data  set $sql where id='$id'");
				
				
				echo "<script>alert('修改成功');window.location.href='user_my.php';</script>";
				 
				}
				
				?>
  
		
		</div>
	<!--右边-->



</div>
	
	


<div class="row juzhong">

<?php require_once 'user_foot.php';	?>

</div>


</body>
 
</html>