tjoder.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. require('SendSms.php');
  3. $goods = $_POST['goods'];
  4. $name = $_POST['name'];
  5. $uid = $_POST['uid'];
  6. $phone = $_POST['phone'];
  7. $sf = $_POST['sf'];
  8. $city = $_POST['city'];
  9. $xian = $_POST['xian'];
  10. $dizhi = $_POST['dizhi'];
  11. $oderid = $_POST['oderid'];
  12. $time = $_POST['time'];
  13. $channel = $_POST['channel'];
  14. $price = $_POST['price'];
  15. include_once("../untils/conn.php");
  16. if ($con) {
  17. mysqli_query($con, "set names utf8");
  18. $data_query = mysqli_query($con, "select * from oder where uid='$uid'");
  19. $count = mysqli_num_rows($data_query);
  20. if ($count > 5) {
  21. // 用户已经申请过了,返回状态码1和提示信息
  22. $response = array('status' => 1, 'msg' => '您申请的订单已超限,请联系客服');
  23. echo json_encode($response);
  24. } else {
  25. // 判断$channel变量是否为空,如果为空则将其赋值为null
  26. if(empty($channel)){
  27. $channel = 0;
  28. }
  29. $data_insert = mysqli_query($con, "insert into oder(goods,name,uid,phone,sf,city,xian,dizhi,oderid,time,price,channel) values('$goods','$name','$uid','$phone','$sf','$city','$xian','$dizhi','$oderid','$time','$price','$channel')");
  30. if ($data_insert) {
  31. // 申请成功,返回状态码0和提示信息
  32. $response = array('status' => 0, 'msg' => '申请成功');
  33. echo json_encode($response);
  34. // 判断$status是否为0,如果是则执行$sendSms()函数
  35. if ($response['status'] == 0) {
  36. sendSms($appId, $appKey, $phoneNumber, $templateId, $smsSign);
  37. }
  38. } else {
  39. // 信息不全,返回状态码-1和提示信息
  40. $response = array('status' => -1, 'msg' => '信息不全,请输入全部信息');
  41. echo json_encode($response);
  42. // echo "Error updating record: " . $con->error;
  43. }
  44. }
  45. }