查看文件: market_add2.php
大小: 16.42 KB
类型: application/octet-stream
<?php require_once('../Connections/BE2.php'); ?> <?php if (!isset($_SESSION)){ session_start(); } if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) { $wwwpath='/www2/skybni'; $picpath= "/number_jpg/c_".$_POST['si10b']; $spicpath= "/number_jpgs/c_".$_POST['si10b']; $tfile="fileToUpload1"; $wimgext=''; $img_ext_array=array("jpg","jpeg","png","gif"); if($_FILES[$tfile]["name"]<>''){ $ext= explode('.',$_FILES[$tfile]['name']) ; $imgext=strtolower($ext[count($ext)-1]); //取最後一筆 if(in_array($imgext,$img_ext_array)){ $spic=$wwwpath.$spicpath.".".$imgext; move_uploaded_file($_FILES[$tfile]["tmp_name"],$spic); $chk_file=true; while($chk_file) { if (file_exists($spic)){ $chk_file=false; } } //$pic=$wwwpath.$picpath.".".$imgext; $picn=$wwwpath.$spicpath.".png"; //$extension = strtolower(pathinfo($filename, PATHINFO_EXTENSION)); switch ($imgext) { case 'jpg': case 'jpeg': $image = imagecreatefromjpeg($spic); break; case 'gif': $image = imagecreatefromgif($spic); break; case 'png': $image = imagecreatefrompng($spic); break; } imagepng($image, $picn); $chk_file=true; $c=time()+10; $ff=0; while($chk_file) { if (file_exists($picn)){ $ff=1; $chk_file=false; } $c1=time(); if($c1>$c){ $chk_file=false; } } if($ff>0){ $repic ='/www2/skybni/number_jpg/c_'.$_POST['si10b'].".png"; $syscall_3b="/usr/local/bin/convert $picn -resize 100x100 -size 100x100 xc:white +swap -gravity center -composite $repic"; $output2=`$syscall_3b`; } } } $updateSQL = sprintf("UPDATE shop5 SET si5=%s, si6=%s,si6a=%s, si11=%s, si12=%s, si13=%s, si14=%s, sicf=%s, address_id=%s WHERE si1=%s", GetSQLValueString($_POST['si5'], "text"), GetSQLValueString($_POST['si6'], "text"), GetSQLValueString($_POST['si6a'], "text"), GetSQLValueString($_POST['si11'], "text"), GetSQLValueString($_POST['si12'], "text"), GetSQLValueString($_POST['si13'], "text"), GetSQLValueString($_POST['si14'], "text"), GetSQLValueString($_POST['sicf'], "text"), GetSQLValueString($_POST['address_id'], "int"), GetSQLValueString($_POST['si1'], "int")); mysql_select_db($database_BE2, $BE2); $Result1 = mysql_query($updateSQL, $BE2) or die(mysql_error()); $write='資料已更新...'; // $updateGoTo = $_POST["url"]; // echo $upSQL; // header(sprintf("Location: %s", $updateGoTo)); echo "<script>alert('".$write."');</script>"; } if( $_SESSION['login_memid']<1){ exit;} $colname_Rt2 = $_SESSION['login_memid']; //-1 //$_SESSION['login_memid'] //$query_Rt2 = sprintf("SELECT * FROM company WHERE mid = %s", GetSQLValueString($_SESSION['login_memid'], "int")); mysql_select_db($database_BE2, $BE2); $query_Rcid = sprintf("SELECT coid FROM company WHERE mid ='%s'",$colname_Rt2); $Rcid = mysql_query($query_Rcid, $BE2) or die(mysql_error()); $row_Rcid = mysql_fetch_assoc($Rcid); $totalRows_Rcid = mysql_num_rows($Rcid); $coid=$row_Rcid['coid']; mysql_free_result($Rcid); $qr1 = sprintf("SELECT a.*,b.* FROM shop5 as a,address as b where a.si10b='%s' AND a.address_id =b.address_id",$coid); mysql_select_db($database_BE2, $BE2); $query_Rt2 = $qr1; $Rt2 = mysql_query($query_Rt2, $BE2) or die(mysql_error()); $row_Rt2 = mysql_fetch_assoc($Rt2); $totalRows_Rt2 = mysql_num_rows($Rt2); if($totalRows_Rt2==0){ mysql_free_result($Rt2); $updateSQL = sprintf("INSERT INTO shop5 (si10,si10b,sicf,address_id)VALUES('0','%s','N','1')",$coid ); mysql_select_db($database_BE2, $BE2); $Result1 = mysql_query($updateSQL, $BE2) or die(mysql_error()); mysql_select_db($database_BE2, $BE2); $query_Rt2 = $qr1; $Rt2 = mysql_query($query_Rt2, $BE2) or die(mysql_error()); $row_Rt2 = mysql_fetch_assoc($Rt2); $totalRows_Rt2 = mysql_num_rows($Rt2); } mysql_select_db($database_BE2, $BE2); // address_id county district street $query_Rot2 = "SELECT distinct(county) FROM address where 1 order by county"; $Rot2 = mysql_query($query_Rot2, $BE2) or die(mysql_error()); $row_Rot2 = mysql_fetch_assoc($Rot2); $totalRows_Rot2 = mysql_num_rows($Rot2); mysql_select_db($database_BE2, $BE2); // address_id county district street $query_Rat2 = sprintf("SELECT distinct(district) FROM address where county='%s' order by district",$row_Rt2['county']); $Rat2 = mysql_query($query_Rat2, $BE2) or die(mysql_error()); $row_Rat2 = mysql_fetch_assoc($Rat2); $totalRows_Rat2 = mysql_num_rows($Rat2); $district=$row_Rt2['district']; mysql_select_db($database_BE2, $BE2); // address_id county district street $query_Rbt2 = sprintf("SELECT address_id,street FROM address where county='%s' AND district='%s' order by street",$row_Rt2['county'], $district); $Rbt2 = mysql_query($query_Rbt2, $BE2) or die(mysql_error()); $row_Rbt2 = mysql_fetch_assoc($Rbt2); $totalRows_Rbt2 = mysql_num_rows($Rbt2); ?> <div class="main "> <div class="row"> <div class="col-lg-12"> <h3 class="page-header"><i class="fa fa-indent"></i>街道網店商城</h3> <ol class="breadcrumb"> <li><i class="fa fa-home"></i><a href="index.html">首頁</a></li> <li><i class="fa fa-list-alt"></i><a href="#">企業資料</a></li> <li><i class="fa fa-indent"></i>街道網店商城</li> </ol> </div> </div> <div class="row"> <div class="col-sm-6"> <div class="panel panel-default"> <div class="panel-heading"> <h2><i class="fa fa-indent red"></i><strong>街道網店商城</strong></h2> </div> <div class="panel-body"> <h3 align="center">街道網店商城</h3><br> <form action="" method="post" name="form1" id="form1" enctype="multipart/form-data"> <div class="form-group"> <label class="col-md-4 control-label" for="si5">商店名稱(商家抬頭):</label> <span class="col-md-8"> <input type="hidden" name="MM_update" value="form1" /> </span> <div class="col-md-8"> <input name="si5" type="text" id="si5" value="<?= $row_Rt2['si5'] ?>" maxlength="4" /> <input type="hidden" name="si10b" id="si10b" value="<?= $row_Rt2['si10b'] ?>" /> <input name="si1" type="hidden" id="si1" value="<?= $row_Rt2['si1'] ?>" size="3" /> <input name="url" type="hidden" id="url" value="<?php echo $_SERVER['HTTP_REFERER']; ?>" /> <input id="address_id" name="address_id" type="hidden" value="<?= $row_Rt2['address_id'] ?>" readonly="readonly" /> <span class="help-block"> </span> </div> </div> <div class="form-group"> <label class="col-md-3 control-label" for="city">縣市:</label> <div class="col-md-9"> <select name="city" id="city" class="form-control placeholder col-xs-12 col-sm-4 mb-4" onchange="Selectcity()"> <? do { ?> <option value="<?= $row_Rot2['county']; ?>" <?= ($row_Rot2['county']==$row_Rt2['county'])?'selected="selected"':""; ?>><?= $row_Rot2['county']; ?></option> <?php } while ($row_Rot2 = mysql_fetch_assoc($Rot2)); ?> </select> <span class="help-block"></span> </div> </div> <div class="form-group"> <label class="col-md-3 control-label" for="district">區域:</label> <div class="col-md-9"> <select name="district" id="district" class="form-control placeholder col-xs-12 col-sm-4 mb-4" onchange="Selectstreet();"> <? do { ?> <option value="<?= $row_Rat2['district']; ?>" <?= ($row_Rat2['district']==$row_Rt2['district'])?'selected="selected"':""; ?>><?= $row_Rat2['district']; ?></option> <? } while ($row_Rat2 = mysql_fetch_assoc($Rat2)); ?> </select> <span class="help-block"></span> </div> </div> <div class="clearfix"> </div> <div class="form-group"> <label class="col-md-3 control-label" for="addr1">鄉鎮:</label> <div class="col-md-9"> <select name="street" id="street" class="form-control placeholder col-xs-12 col-sm-4 mb-4" onchange="show_id()"> <? do { ?> <option value="<?= $row_Rbt2['address_id']; ?>" <?= ($row_Rbt2['street']==$row_Rt2['street'])?'selected="selected"':""; ?>><?= $row_Rbt2['street']; ?></option> <? } while ($row_Rbt2 = mysql_fetch_assoc($Rbt2)); ?> </select> <span class="help-block"></span> </div> </div> <div class="form-group"> <label class="col-md-3 control-label" for="addr1">巷弄:</label> <div class="col-md-9"> <table width="100%" border="0" cellpadding="0"> <tr> <td width="15%" height="4"><input name="si11" type="text" class="form-control g-color-black g-bg-white g-bg-white--focus g-brd-gray-light-v4 g-brd-primary--hover rounded g-py-10 g-px-15" id="si11" placeholder="巷" value="<?= $row_Rt2['si11'] ?>" size="4" maxlength="4" /></td> <td width="12%">巷</td> <td width="15%"><input name="si12" type="text" class="form-control g-color-black g-bg-white g-bg-white--focus g-brd-gray-light-v4 g-brd-primary--hover rounded g-py-10 g-px-15" id="si12" placeholder="弄" value="<?= $row_Rt2['si12'] ?>" size="4" maxlength="4" /></td> <td width="12%">弄</td> <td width="15%"><input name="si13" type="text" required="required" class="form-control g-color-black g-bg-white g-bg-white--focus g-brd-gray-light-v4 g-brd-primary--hover rounded g-py-10 g-px-15" id="si13" placeholder="號" onchange="show_id()" value="<?= $row_Rt2['si13'] ?>" size="4" maxlength="4"/></td> <td width="12%">號</td> <td width="15%"><input name="si14" type="text" class="form-control g-color-black g-bg-white g-bg-white--focus g-brd-gray-light-v4 g-brd-primary--hover rounded g-py-10 g-px-15" id="si14" placeholder="樓" onchange="show_id()" value="<?= $row_Rt2['si14'] ?>" size="4" maxlength="4"/></td> <td width="13%">樓</td> </tr> </table> </div> </div> <div class="form-group"> <label class="col-md-3 control-label" for="si6">地址:</label> <div class="col-md-9"> <input id="si6" name="si6" type="text" required="required" class="form-control g-color-black g-bg-white g-bg-white--focus g-brd-gray-light-v4 g-brd-primary--hover rounded g-py-10 g-px-15" placeholder="地址" value="<?= $row_Rt2['si6'] ?>" readonly="readonly"/> <input id="si6a" name="si6a" type="hidden" value="<?= $row_Rt2['si6a'] ?>" /> <span class="help-block"></span> </div> </div> <div class="clearfix"> </div> <div class="form-group"> <label class="col-md-3 control-label" for="fileToUpload1">圖檔:</label> <div class="col-md-9"> <input name="fileToUpload1" type="file" id="fileToUpload1" /> <span class="help-block">圖檔(jpg,png) : Size 100 x 100 px </span> </div> </div> <div class="clearfix"> </div> <div class="form-group"> <label class="col-md-3 control-label" for="sicf">啟用:</label> <div class="col-md-9"> <select name="sicf" id="sicf" class="form-control placeholder col-xs-12 col-sm-4 mb-4" > <option value="Y" <?= ($row_Rt2['sicf']=='Y')?'selected="selected"':""; ?>>啟用 Y</option> <option value="N" <?= ($row_Rt2['sicf']=='N')?'selected="selected"':""; ?>>停用 N</option> </select> <span class="help-block"></span> </div> </div> <div class="clearfix"> </div> <div class="form-group"> <img class="col-md-3" src="/number_jpg/c_<?= $coid ?>.png" width="100" height="100" /> <div class="col-md-9" style="text-align:center;valign:middle;"> <br><br><input type="submit" value="更新記錄" /> </div> </div> </form> <script> function Selectstreet() { var county= $("#city").val(); // $(city).find(':selected')[0].id; var district = $("#district").val(); //.find(':selected')[0].id; $.ajax({ type: 'POST', url: 'SelectstreetApi.php', data: { 'county': county,'district':district }, success: function (data) { // the next thing you want to do var $street = $('#street'); $street.empty(); $("select#street").html(data); } }); } function Selectcity() { var county= $("#city").val(); // $(city).find(':selected')[0].id; $.ajax({ type: 'POST', url: 'SelectcityApi.php', data: {'county': county}, success: function (data) { // the next thing you want to do var $street = $('#street'); $street.empty(); var $district = $('#district'); $district.empty(); $("select#district").html(data); Selectstreet(); } }); } function show_id(){ //var s=$('#city').find(":selected").text(); var s=$('#city').val() +$('#district').val()+$.trim($('#street').find(":selected").text()); //$('#aioConceptName :selected').text(); // var county= $("#city").val(); $('#si6a').val(s); s=s+$('#si13').val()+'號'; if($('#si14').val()!=''){ s=s+$('#si14').val()+'樓'; } $('#si6').val(s); $('#address_id').val($('#street').val()); // alert(1); } </script> <?php mysql_free_result($Rt2); mysql_free_result($Rot2); mysql_free_result($Rat2); mysql_free_result($Rbt2); ?>
保存
取消
返回文件列表