<?php
error_reporting(0);
require_once("../../check.php");
require_once("../../../config.php");
isset($_POST['jinbi'])?$jinbi=$_POST['jinbi']:$jinbi=null;
$usersql = "select * from dunling_user where username='$username'";
$userery = mysql_query($usersql,$config);
$user = mysql_fetch_array($userery);
$usermoney = $user['money'];


$minpaysql = "select rmbvsjinbi from dunling_config where id='1'";
$minpayery = mysql_query($minpaysql,$config);
$pay = mysql_fetch_array($minpayery);
$bili = $pay['rmbvsjinbi'];
$rmb = $jinbi/$bili;//计算所需要的人民币

if($rmb>$usermoney){
    echo 'usermoneyerror';
    exit;
}


$zengsql = "update dunling_user set money=money-'$rmb',zmoney=zmoney-'$rmb',jinbi=jinbi+'$jinbi' where username='$username'";
$zengery = mysql_query($zengsql,$config);
mysql_close($config);
echo 'ok';
exit;
?>