}
if ($cur_bet_value > $cur_points) {
    $lastError .= "Sorry you don't have sufficient points avilable to bet on !! <br>";
}
if ($lastError == "") {
    // Now assign new card to discarded card
    for ($i = 1; $i < 6; $i++) {
        if ($_POST['cardv' . $i] == 'D') {
            unset($cur_hand[$i - 1]);
            $cur_hand[$i - 1] = $cur_game->pickCard();
        }
    }
    // calculate points now
    $cur_hand_value = $cur_game->calculateHand($cur_hand);
    $cur_hand_points = $cur_bet_value * $cur_game->calculatePoints($cur_hand_value);
    // create new deal and store as current game.
    $new_game = new pokerVideo();
    $new_game->Deal();
    $fv = array();
    $fv['id'] = $guserid;
    $fv['cur_hand'] = serialize($new_game->pickHand());
    $fv['win_hand'] = serialize($cur_hand);
    $fv['deck'] = serialize($new_game->currentDeck);
    $db->mysqlAddUpdateRow("members", $fv);
    $pv = array();
    $pv['mid'] = $guserid;
    $pv['edate'] = date("YmdHis");
    $pv['points'] = $cur_hand_points;
    $pv['game'] = 'V';
    $db->mysqlAddUpdateRow("points", $pv);
}
$tr = $db->mysqlFetchRow(" SELECT sum(points) pts FROM points WHERE mid='{$guserid}' ");
$cur_points = $tr['pts'];
$tr = $db->mysqlFetchRow(" SELECT points FROM points WHERE mid='{$guserid}' ORDER BY id DESC LIMIT 1 ");
$last_points = $tr['points'];
$cur_hand = $win_hand = $deck = array();
$cuser = $db->mysqlFetchRow(" SELECT * FROM members WHERE id='{$guserid}' ");
if ($cuser['cur_hand'] != "") {
    $cur_hand = unserialize($cuser['cur_hand']);
}
if ($cuser['win_hand'] != "") {
    $win_hand = unserialize($cuser['win_hand']);
}
if ($cuser['deck'] != "") {
    $deck = unserialize($cuser['deck']);
}
$cur_game = new pokerVideo();
$cur_game->Deal($deck);
if (empty($cur_hand)) {
    $cur_hand = $cur_game->pickHand();
}
if (!empty($win_hand)) {
    $cur_hand_value = $cur_game->calculateHand($win_hand);
}
$fv = array();
$fv['id'] = $guserid;
$fv['cur_hand'] = serialize($cur_hand);
$fv['win_hand'] = "";
$fv['deck'] = serialize($cur_game->currentDeck);
$db->mysqlAddUpdateRow("members", $fv);
?>
<body topmargin=0 BGCOLOR="black">