/** * Generate fields */ function generateFields() { foreach (static::$generated as $field => $method) { if ($method == 'uniqid' && !$this->{$field}) { $this->{$field} = newid(); } } }
$title_err = "Phone number must begin with +"; } else { if (!is_numeric(substr($phone, 1, strlen($phone)))) { $error = True; $title_err = "Enter valid phone number"; } } $gender = testinput($_POST["gender"]); $state = testinput($_POST["state"]); if (!$error) { $conn = new mysqli($servername, $username, $userpassword, $dbname); if ($conn->connect_error) { die("Connection failed " . $conn->error); } do { $id = newid(); $stmt = $conn->prepare("insert into " . $tablename . "(id, name, email, password, gender, address, state, pin, phone, time) \n\t\t\t\tvalues(?, ?, ?, ?, ?, ?, ?, ?, ?, ?) "); $stmt->bind_param('ssssssssss', $id, $name, $email, $password, $gender, $address, $state, $pin, $phone, date("Y-m-d H:i:s")); $stmt->execute(); header("Location: login.php"); exit; } while ($stmt->error); $conn->close(); } } function newid() { $key = mt_rand(1, 1000000); return strval($key); } function testinput($data)
/** * 新增商品 */ public function insert() { $rd = array('status' => -1); $shopId = -1; // 粗卡云平台 $data = array(); $data["goodsSn"] = I("goodsSn"); $data["goodsName"] = I("goodsName"); $data["goodsImg"] = I("goodsImg"); $data["goodsThums"] = I("goodsThumbs"); $data["shopId"] = $shopId; //session('RTC_USER.shopId'); $data["marketPrice"] = (int) I("marketPrice"); $data["shopPrice"] = (int) I("shopPrice"); $data["goodsStock"] = (int) I("marketPrice"); $data["isBook"] = (int) I("isBook"); $data["bookQuantity"] = (int) I("bookQuantity"); $data["warnStock"] = (int) I("warnStock"); $data["goodsUnit"] = I("goodsUnit"); $data["isBest"] = (int) I("isBest"); $data["isBest"] = (int) I("isBest"); $data["isRecomm"] = (int) I("isRecomm"); $data["isNew"] = (int) I("isNew"); $data["isHot"] = (int) I("isHot"); //如果商家状态不是已审核则所有商品只能在仓库中 // if($shopStatus[0]['shopStatus']==1){ // $data["isSale"] = (int)I("isSale"); // }else{ // $data["isSale"] = 0; // } $data["isSale"] = 1; $data["goodsCatId1"] = (int) I("goodsCatId1"); $data["goodsCatId2"] = (int) I("goodsCatId2"); $data["goodsCatId3"] = (int) I("goodsCatId3"); $data["shopCatId1"] = (int) I("shopCatId1"); $data["shopCatId2"] = (int) I("shopCatId2"); $data["goodsDesc"] = I("goodsDesc"); $data["attrCatId"] = (int) I("attrCatId"); $data["isShopRecomm"] = 0; $data["isIndexRecomm"] = 0; $data["isActivityRecomm"] = 0; $data["isInnerRecomm"] = 0; $data["goodsStatus"] = 1; // ($GLOBALS['CONFIG']['isGoodsVerify']==1)?0:1; $data["goodsFlag"] = 1; $data["createTime"] = date('Y-m-d H:i:s'); $miaoshaId = newid(); $data["miaoshaId"] = $miaoshaId; //子表 $miaosha = array(); $miaosha["miaoshaId"] = $data["miaoshaId"]; $miaosha["subtitle"] = I("subtitle"); $miaosha["maxqishu"] = (int) I("maxqishu"); //最大期数 $miaosha["xiangou"] = (int) I("xiangou"); $zongrenshu = (int) I("marketPrice"); $miaosha["miaoshaStatus"] = 0; // $miaosha["qishu"] = 1; //期数', $miaosha["zongrenshu"] = $zongrenshu; //'总人数', $miaosha["canyurenshu"] = 0; //'参与人数', $miaosha["shengyurenshu"] = $zongrenshu; // '剩余数', $miaosha["jishijiexiao"] = (int) I("jishijiexiao"); // '即时揭晓', if ($miaosha["jishijiexiao"] > 0) { $addTime = (int) $miaosha["jishijiexiao"]; $miaosha["lastTime"] = date('Y-m-d H:i:s', strtotime("+{$addTime} hour")); } if ($zongrenshu > 100000) { $rd['status'] = -2000; $rd['key'] = "商品秒杀人次不能大于十万次"; return $rd; } $rd['data'] = array('miaoshaId' => $miaoshaId, 'qishu' => $miaosha["qishu"], 'count' => $miaosha["zongrenshu"]); if ($this->checkEmpty($data, true)) { $data["brandId"] = (int) I("brandId"); $data["goodsSpec"] = I("goodsSpec"); $data["goodsKeywords"] = I("goodsKeywords"); $m = M('goods'); $goodsId = $m->add($data); if (false !== $goodsId) { $this->add($miaosha); $rd['status'] = 1; //保存相册 $gallery = I("gallery"); if ($gallery != '') { $str = explode(',', $gallery); foreach ($str as $k => $v) { if ($v == '') { continue; } $str1 = explode('@', $v); $data = array(); $data['shopId'] = $shopId; // session('RTC_USER.shopId'); $data['goodsId'] = $goodsId; $data['goodsImg'] = $str1[0]; $data['goodsThumbs'] = $str1[1]; $m = M('goods_gallerys'); $m->add($data); } } } } else { $rd['status'] = -1000; } return $rd; }