/** * @param $businessId * @param $shopfrontPic * @param $licencePic * @throws Exception */ function updateBusinessInfor($businessId, $shopfrontPic, $licencePic) { $businessName = $_REQUEST['$businessName']; $startTime = $_REQUEST['$startTime']; $endTime = $_REQUEST['$endTime']; $lon = $_REQUEST['$lon']; $lat = $_REQUEST['$lat']; $mobilePhone = $_REQUEST['$mobilePhone']; $sortF = $_REQUEST['$sortF']; $sortS = $_REQUEST['$sortS']; $privileges = $_REQUEST['$privileges']; $description = $_REQUEST['$description']; $serviceindex = $_REQUEST['$serviceindex']; $province = $_REQUEST['$province']; $city = $_REQUEST['$city']; $addresDetail = $_REQUEST['$addresDetail']; $fixTelephone = $_REQUEST['$fixTelephone']; // 字符必须添加'',数字不必添加 $sqlUpdate = "UPDATE\n `business`\n SET\n `name` = '{$businessName}',\n `sortF` = {$sortF},\n `sortS` = {$sortS},\n `privileges` = '{$privileges}',\n `picUrl` = '{$shopfrontPic}',\n `description` = '{$description}',\n `businessSTime` = {$startTime},\n `businessETime` = {$endTime},\n `licensePicUrl` = '{$licencePic}',\n `mobilePhone` = '{$mobilePhone}',\n `serviceindex` = {$serviceindex},\n `longitude` = {$lon},\n `latitude` = {$lat},\n `province` = {$province},\n `city` = {$city},\n `addresDetail` = '{$addresDetail}',\n `fixTelephone` = '{$fixTelephone}'\n WHERE\n `business`.`id` = {$businessId}"; $connect = db::getInstance()->connect(); $result = mysqli_query($connect, $sqlUpdate); if ($result) { echo '更新基本数据成功'; } else { echo response::show(201, '更新基本数据失败'); } }
public static function storeLicenceImage($imageName, $imageData) { if ($imageData == '') { echo 'licencePic图片为空'; } else { $fullImageName = cLicencePath . $imageName; if (self::storeImage($fullImageName, $imageData)) { echo 'licencePic图片保存成功'; return cPicUrlHeader . $fullImageName; } else { echo response::show(201, 'licencePic图片保存失败'); } } }
header("Content-Type: text/html; charset=utf-8"); /** * Created by PhpStorm. * User: Administrator * Date: 2015/9/16 * Time: 20:09 */ const cPicUrlHeader = 'http://192.168.199.104:8090/images/'; // 返回给客户端图片url的头部 const cPicStorePath = '/Users/wsk/pb_cs/www/uploadImages/'; // 客户端上传的图片在服务器中存放的路径 require_once './tools/db.php'; require_once './tools/response.php'; $img = base64_decode($_REQUEST['picStr']); $picName = time() . '.jpg'; // 1、将图片的url,对应的商户id,保存到数据库中 $picUrl = cPicUrlHeader . $picName; $connect = db::getInstance()->connect(); $sql = 'SELECT pwd FROM `account` WHERE `phone` = ' . $phone; $result = mysqli_query($sql, $connect); $row = mysqli_fetch_object($result); // 2、将图片保存到指定路径下面 $picStorePath = cPicStorePath . $picName; $fileLength = file_put_contents($picStorePath, $img); // 返回值为图片的长度 if ($fileLength > 0) { echo response::show(200, '上传图片成功'); } else { echo response::show(201, '上传图片失败'); }
<?php header("Content-Type: text/html; charset=utf-8"); require_once './tools/db.php'; require_once './tools/response.php'; // php5.5以后mysql全部替换成mysqli或者使用下面两行的任一行 // error_reporting(E_ALL ^ E_DEPRECATED); // error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE); /** * Created by PhpStorm. * User: new1 * Date: 2015/9/13 * Time: 16:46 */ $connect = db::getInstance()->connect(); $sql = 'select * from account'; $result = mysqli_query($sql, $connect); echo mysqli_num_rows($result) . ' 行 ' . mysqli_num_fields($result) . ' 列 ' . "<br />" . "<br />" . "<br />"; echo '结果' . $result . '结果' . "<br />"; $resList = array(); while ($row = mysqli_fetch_object($result)) { $model = array('phone' => &$row->phone, 'pwd' => &$row->pwd); $resList[] = $model; // echo $row->id.'手机号码:'. $row->phone. ' 密码:'.$row->password."<br />"; } echo response::show(200, '成功', $resList);
/** * Created by PhpStorm. * User: Administrator * Date: 2015/9/11 * Time: 22:08 */ //$a = isset($GLOBALS["HTTP_RAW_POST_DATA"]) ? $GLOBALS["HTTP_RAW_POST_DATA"] : "" ; //$a = $GLOBALS["HTTP_RAW_POST_DATA"]; // $phone = 'zhxxxxxang'; // $password = '******'; //$json = json_decode($a,true); //$json = file_get_contents('php://input'); //$json = json_decode($json); //echo $json[0]->app_slug; header("Content-Type: text/html; charset=utf-8"); require_once './tools/db.php'; require_once './tools/response.php'; $phone = $_REQUEST['phone']; // 获取客户端传递过来的用户名 $pwd = $_REQUEST['pwd']; // 获取客户端传递过来密码 $connect = db::getInstance()->connect(); $sql = 'SELECT pwd FROM `account` WHERE `phone` = ' . $phone; $result = mysqli_query($sql, $connect); $row = mysqli_fetch_object($result); if ($row->pwd == $pwd) { echo response::show(200, '登陆成功'); } else { echo response::show(205, '登陆失败'); }
// ../这个是返回上一级 require_once '../../tools/db.php'; require_once '../../tools/response.php'; $img = base64_decode($_POST['picStr']); // 图片的内容 $picName = $_POST['businessID'] . '_' . time() . '.jpg'; // 图片的名字 // 1、将图片的url,对应的商户id,保存到数据库中 $businessID = $_POST['businessID']; // 商户id $categoryID = $_POST['categoryID']; // 菜品分类id $picUrl = 'http://192.168.199.104:8090/images/' . $picName; // 图片的下载url $dishName = $_POST['dishName']; // 菜品名字 $price = $_POST['price']; // 菜品价格 $connect = db::getInstance()->connect(); $sql = "SELECT * FROM dish WHERE businessID = " . $businessID . " AND categoryID = " . $categoryID . " AND dishName = " . "'" . $dishName . "'"; $result = mysqli_query($sql, $connect); if (mysqli_num_rows($result) > 0) { echo response::show(206, '该菜品已经被登记'); } else { $sql = "INSERT INTO `test`.`dish` (`businessID`, `categoryID`, `picUrl`, `dishName`, `price`) VALUES (" . $businessID . "," . $categoryID . "," . "'" . $picUrl . "'" . "," . "'" . $dishName . "'" . "," . $price . ")"; if (mysqli_query($sql, $connect)) { echo response::show(200, '菜品登记注册成功'); } else { echo response::show(203, '菜品登记失败' . $sql); } }
<?php header("Content-Type: text/html; charset=utf-8"); require_once './tools/db.php'; require_once './tools/response.php'; $phone = $_POST['phone']; // 获取客户端传递过来的用户名 $pwd = $_POST['pwd']; // 获取客户端传递过来密码 if ($pwd == '') { echo response::show(201, '密码不能为空'); } else { if ($phone == '') { echo response::show(202, '手机号码不能为空'); } else { $connect = db::getInstance()->connect(); $sql = 'SELECT * FROM `account` WHERE `phone` = ' . $phone; $result = mysqli_query($sql, $connect); if (mysqli_num_rows($result) > 0) { echo response::show(204, '该手机号已经被注册'); } else { $sql = 'INSERT INTO `account`(`id`, `phone`, `pwd`) VALUES (NULL, ' . $phone . ',' . $pwd . ')'; if (mysqli_query($sql, $connect)) { echo response::show(200, '注册成功'); } else { echo response::show(203, '注册失败'); } } } }