html5新增输入型,HTML5号码输入型步骤属性100

Amount:

这种形式的用PHP作出MySQL数据库中插入数据。 INPUT 1.50 OUTPUT在数据库中150.00

如何解决这个问题?我是否需要在php编码部分使用$ pr_amount/100类型的代码,或者是否有其他方法。没有step =“0.01”,它不会以点或美元的分值取小数部分。

PHP部分: payment.inc.php

if (isset($_POST['pr_amount'], $_POST['pr_processor'],$_POST['pr_comment'])) {

// Sanitize and validate the data passed in

$pr_amount = filter_input(INPUT_POST, 'pr_amount', FILTER_SANITIZE_NUMBER_FLOAT);

$pr_processor = filter_input(INPUT_POST, 'pr_processor', FILTER_SANITIZE_STRING);

$pr_comment = filter_input(INPUT_POST, 'pr_comment', FILTER_SANITIZE_STRING);

$user_id = htmlentities($_SESSION['user_id']);

// for checking minimum payout allowed

if ($pr_amount < 1) {

// If it's not, something really odd has happened

$error_msg_payout .= '

Minimum Payout is $1.00, for INR withdraw Minimum payout is Rs.100

';

}

if(empty($pr_amount || $pr_comment)) {

$error_msg_payout .= '

User must input all field

';

}

// checking if pr amount is above the available balance

$stmt_balance = $mysqli->prepare("SELECT current_balance FROM client WHERE user_id = ?");

$stmt_balance->bind_param('i', $user_id);

$stmt_balance->execute();

$stmt_balance->store_result();

if($stmt_balance < $pr_amount){

// If it's not, something really odd has happened

$error_msg_payout .= '

Payment request amount is greater than the available balance.

';

}

$stmt_balance->close();

//-------For checking pr comment validity

if (strlen($pr_comment) > 150) {

// If it's not, something really odd has happened

$error_msg_payout .= '

Payment instruction should be within 150 charecters

';

}

if (!ctype_alpha(str_replace(' ', '',$pr_comment))) {

$error_msg_payout .= '

Payment Instruction Include disallowed charecters

';

}

if (empty($error_msg_payout)) {

// Insert the new account into the database

if ($insert_stmt_payout = $mysqli->prepare("INSERT INTO payment (user_id,pr_amount,pr_comment,pr_processor)

SELECT ?, ?, ?, pr_processor FROM paymentlist WHERE pr_processor = ?")) {

$insert_stmt_payout->bind_param('idss', $user_id,$pr_amount,$pr_comment,$pr_processor);

// Execute the prepared query.

if (! $insert_stmt_payout->execute()) {

header('Location: ../error.php?err=AddPayment failure: INSERT');

exit();

}

}

//---deducting balance after succesful request

$stmt_deduct = $mysqli->prepare("UPDATE client SET current_balance = (current_balance-?) WHERE user_id = ?");

$stmt_deduct->bind_param('di', $pr_amount,$user_id);

$stmt_deduct->execute();

if (! $stmt_deduct->execute()) {

header('Location: ../error.php?err=AddPayment failure: INSERT AMOUNT');

exit();

}

$stmt_deduct->close();

header('Location: ./payment.php');

exit();

}

}

HTML部分: payment.php

Add Request:

$stmt = $mysqli->prepare('SELECT pr_processor FROM paymentlist ');

$stmt->execute(); // Execute the prepared query.

$stmt->bind_result($pr_processor);

$stmt->store_result();

echo "";

while($stmt->fetch()) {

echo "" . $pr_processor . "";

}

$stmt->close();

echo "";

?>

Amount:

Payment Instruction:

注:如果我不去使用步骤,那么它只需要整数,输入的输出完全可以。但我要求用小数点输入货币价值。

2017-06-19

mimi

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值