【发布时间】:2019-10-04 04:42:41
【问题描述】:
我设置了 3 个 sql 表:'client' 'inv' 和 'wit' 数据库连接工作正常,代码中的其他页面也可以正常工作,但我遇到了这个特定页面的问题。
我有一个页面new.php:
<?php session_start();
if(!isset($_SESSION["email"]))
{
header("location:../login.php");
exit;
}
?>
<!DOCTYPE html>
<html lang="en">
<head></head>
<body>
<?php include("header.php"); ?>
<form action="withdraw.php" method="post" class="m-form m-form--label-align-right m-form--fit" id="withdrawalForm">
<input type="hidden" name="email" value="<?php echo $userVal['email']; ?>" />
<input type="hidden" name="w_date" value="<?php echo date("d-m-Y"); ?>" />
<input type="hidden" name="w_status" value="Pending" />
<input type="hidden" name="balance" value="<?php echo $userVal['balance']; ?>" />
<input type="text" name="method" value="" />
<input type="text" name="balance" value="$<?php echo $userVal['balance']; ?>" disabled=true readonly />
<input type="number" name="w_amount" value="" placeholder="<?php echo $userVal['balance']; ?> or less" required />
<input type="text" name="wallet" value="" placeholder="Wallet Address" required />
<input type="submit" name="withdraw" value="withdraw" />
</body>
</html>
header.php 有:
<?php
include("pdoconnect.php");
$id = $_SESSION["email"];
$user = $pdotestconn->prepare("SELECT * FROM client JOIN inv ON client.email = inv.email WHERE client.email = :uname ");
$user->bindParam(":uname", $id);
$user->execute();
$userVal = $user->fetch(PDO::FETCH_ASSOC);
然后我有withdraw.php:
<?php
include("pdoconnect.php");
$datei=date("D M d, Y g:i a");
$email = $_POST['email'];
$wdate = $_POST['w_date'];
$method = $_POST['method'];
$wamount = $_POST['w_amount'];
$wstatus = $_POST['w_status'];
$wallet = $_POST['wallet'];
$user = $pdotestconn->prepare("SELECT * FROM client JOIN wit ON client.email = wit.email WHERE client.email = :uname ");
$user->bindParam(":uname", $email);
$user->execute();
$userVal = $user->fetch(PDO::FETCH_ASSOC);
if ($wamount >= $userVal['balance']) {
echo "Insufficient Fund";
} else {
$balance = $userVal['balance'] - $wamount;
$ins = $pdotestconn->prepare("INSERT INTO wit (email,w_date,method,w_amount,w_status,wallet) VALUES (:email,:w_date,:method,:w_amount,:w_status,:wallet)");
$ins->bindParam(":email", $email);
$ins->bindParam(":w_date", $wdate);
$ins->bindParam(":method", $method);
$ins->bindParam(":w_amount", $wamount);
$ins->bindParam(":w_status", $wstatus);
$ins->bindParam(":wallet", $wallet);
$ins->execute();
$up = $pdotestconn->prepare("UPDATE client SET balance = :credit WHERE email = :email ");
$up->bindParam(":credit", $balance);
$up->bindParam(":email", $email);
$up->execute();
echo "ok";
}
?>
每次我尝试提款时,我都会收到“Insufficient Funds”,但那里有足够的资金。
【问题讨论】: