查看文件: market_master.php
大小: 5.63 KB
类型: application/octet-stream
<?php require('system/login.php'); ?> <?php require_once('../Connections/BE2.php'); ?> <?php $write=''; if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) { $tfile1="fileToUpload1"; $imgpath= '/www2/skybni/products/'; $mspic=$_POST['mspic']; $img_ext_array=array("jpg","png"); if(($_POST['set1']=='E') && ($_POST['set2']<>'')){ $mspic=trim($_POST['set2']); } if($_FILES[$tfile1]["name"]<>''){ $ext1= explode('.',$_FILES[$tfile1]['name']) ; $imgext1=strtolower($ext1[count($ext1)-1]); //取最後一筆 if(in_array($imgext1,$img_ext_array)){ $mspic='ma'.date('YmdHis').sprintf("%04d",rand(1,9999)).'.'.$imgext1; $pic1=$imgpath.$mspic; move_uploaded_file($_FILES[$tfile1]["tmp_name"],$pic1); }else{ $write='圖檔錯誤...'; } } if($_POST['msid']==0){ $updateSQL = sprintf("INSERT INTO marketmaster(msname,mspic,mslink)VALUES(%s,%s,%s )", GetSQLValueString($_POST['msname'], "text"), GetSQLValueString($mspic, "text"), GetSQLValueString($_POST['mslink'], "text")); }else{ $updateSQL = sprintf("UPDATE marketmaster set mspic=%s,mslink=%s where msid='%s'", GetSQLValueString($mspic, "text"), GetSQLValueString($_POST['mslink'], "text"), GetSQLValueString($_POST['msid'], "int") ); } mysql_select_db($database_BE2, $BE2); mysql_query($updateSQL, $BE2) or die(mysql_error()); // echo $upSQL; $updateGoTo =$_POST['url']; echo "<script>alert('編輯完成 ..');location.href='".$updateGoTo."';</script>"; } $msid=0; if (isset($_GET['msid'])) { $msid = $_GET['msid']; } $key=''; if (isset($_GET['key'])) { $key = $_GET['key']; } if($msid>0){ mysql_select_db($database_BE2, $BE2); // address_id county district street $query_Rt2 = sprintf("SELECT * FROM marketmaster where msid='%s' order by msid limit 1 ",$msid);; $Rt2 = mysql_query($query_Rt2, $BE2) or die(mysql_error()); $row_Rt2 = mysql_fetch_assoc($Rt2); $totalRows_Rt2 = mysql_num_rows($Rt2); $key=$row_Rt2['msname']; } ?> <div class="row"> <div class="col-md-12"> <div class="panel panel-default"> <div class="panel-heading"> <h3 class="panel-title">街道網店商城-新增</h3> </div> <form action="" method="post" name="form1" id="form1" enctype="multipart/form-data"> <table width="55%" align="center"> <tr valign="baseline"> <th height="38" colspan="3" align="center" valign="middle" nowrap="nowrap"> </th> </tr> <tr valign="baseline"> <th width="24%" height="42" align="center" valign="middle" nowrap="nowrap"><span class="font2">商圈名稱說明:</span></th> <td width="51%" valign="middle"><span class="col-md-8"> <input name="msname" type="text" id="msname" value="<?= $key ?>" maxlength="24" readonly="readonly" /> <br> </span></td> <td width="25%" rowspan="7" valign="baseline"><? if(isset($row_Rt2['mspic'])&& $row_Rt2['mspic']<>''){?><img name="" src="/products/<?= $row_Rt2['mspic'] ?>" width="120" alt="" /><? }?> </td> </tr> <tr valign="baseline"> <th height="42" align="center" valign="middle" nowrap="nowrap"><span class="font2">超連結:</span></th> <td valign="middle"><span class="col-md-8"> <input name="mslink" type="text" id="mslink" value="<?= ($msid>0)?$row_Rt2['mslink']:'' ?>" size="40" maxlength="200"/> <br>商圈介紹.html </span></td> </tr> <tr valign="baseline"> <th height="42" align="center" valign="middle" nowrap="nowrap"><span class="font2">主圖:</span></th> <td valign="middle"><input name="fileToUpload1" type="file" id="fileToUpload1" /></td> </tr> <tr valign="baseline"> <th height="42" align="center" valign="middle" nowrap="nowrap"> </th> <td valign="middle"> <span class="font2">主圖</span> 寬>800px jpg , png </td> </tr> <tr valign="baseline"> </tr> <tr valign="baseline"> <td height="40" align="center" valign="middle" nowrap="nowrap"><span class="col-md-8"> PS: <label for="set1"></label> <select name="set1" id="set1"> <option value="0" selected="selected">內定值</option> <option value="E">直接輸入主圖檔案位置</option> </select> </span></td> <td height="40" align="center" valign="middle" nowrap="nowrap"><span class="col-md-8"> <input name="set2" type="text" id="set2" size="50" maxlength="80" /> </span></td> </tr> <tr valign="baseline"> <td height="40" colspan="2" align="center" valign="middle" nowrap="nowrap"><input type="submit" value="<?= ($msid>0)?'編輯':'新增';?>" /></td> </tr> </table> <input type="hidden" name="MM_update" id="MM_update" value="form1" /> <input name="url" type="hidden" id="url" value="<?= $_SERVER['HTTP_REFERER']; ?>" /> <span class="col-md-8"> <input id="msid" name="msid" type="hidden" value="<?= $msid ?>" /> <input id="mspic" name="mspic" type="hidden" value="<?= ($msid==0)?'': $row_Rt2['mspic'] ?>" /> </span> </form> <div class="clearfix"> </div> <div id="back"><a href="javascript:history.back();"><img src="images/back.gif" alt="回上一頁" title="回上一頁" width="115" height="32" border="0"></a></div> </div> </div> </div> <? if($msid>0){ mysql_free_result($Rt2);} ?>
保存
取消
返回文件列表