<?php
$con=mysqli_connect("127.0.0.1","您的数据库名","您的数据库密码","您的数据库账号");//("数据库地址""数据库用户名","数据库密码","数据库账号")javascript:;
if (mysqli_connect_errno())
{
    echo "连接失败: " . mysqli_connect_error();
}
ini_set("error_reporting","E_ALL & ~E_NOTICE");
$zt ='1';
$mid ='1012';//商户ID
$key = "5eth1mfk53ibm2xhjz3uejer91t6";//通讯密钥
$payId = $_GET['payId'];//商户订单号
$param = $_GET['param'];//创建订单的时候传入的参数
$type = $_GET['type'];//支付方式 ：微信支付为1 支付宝支付为2
$price = $_GET['price'];//订单金额
$reallyPrice = $_GET['reallyPrice'];//实际支付金额
$sign = $_GET['sign'];//校验签名，计算方式 = md5(payId + param + type + price + reallyPrice + 通讯密钥)
//开始校验签名
$_sign =  md5($mid.$payId . $param . $type . $price . $reallyPrice . $key);
if ($_sign != $sign) {
    echo "error_sign";//sign校验不通过
    exit();
}
//$con=mysqli_connect("localhost","数据库用户名","数据库密码","数据库账号");
//mysql_query("update 数据库表名 set `操作金额字段`=传过来的金额 where `user`=$user");
// echo '支付成功';

// $user = $param;
// echo $user;
// echo $param;
// echo $price;
// echo '充值成功';

//$user= SESSION['user1'];
//$url = $url.'?'.$user;
//<a href="$url">充值</a>
//http://pay.haoltw.com/pay/index.php?user=用户账号price=用户金额
//var_dump(mysql_query("update admin set `money`= +$price where `user`=$user"));
//$update = mysql_query("UPDATE `admin` SET `money`=$price WHERE name=$user");//UPDATE `admin` SET `money`=1 WHERE name=1234
$query = "UPDATE `box_user` SET `money`=money+$price WHERE `mid`=$mid";//(admin为数据库表名,money为充值的金额字段名,uer为用户账户ID的字段名)



//   echo $query;


$result = mysqli_query($con,$query);


if ($result){ 
    // mysqli_query($con,"UPDATE `pay_order` SET `state`=$result WHERE `pay_id`=$payId");
         //echo "<p>充值成功！</p>";
         die('success');
 
         }
      else {
         echo "<p>充值失败。</p>";}

//继续业务流程
//echo "商户订单号：".$payId ."<br>自定义参数：". $param ."<br>支付方式：". $type ."<br>订单金额：". $price ."<br>实际支付金额：". $reallyPrice;


?>