我想将我卡的一些数据带到下一页。 但是如果我想通过表单发送数据,用户可以从控制台更改它。
如果我隐藏了输入字段,那么它仍然可以通过控制台进行更改。
<form action="{{url('/checkout')}}" method="post">
@csrf
<input type="hidden" name="total_amount3" value="{{ ($subTotal-($subTotal*$coupon_amount)/100) }}">
<button class="site-btn btn-full" type="submit">Proceed to checkout</button>
</form>
如何在不被用户更改的情况下在下一页发送我的数据?
最佳答案
一旦数据在前端,你无能为力,用户可以通过检查或通过控制台更改它
将变量移至后端
public function checkout(Request $request)
{
$subTotal = $request->subTotal; // Or calculate it here from the products in the cart or whatever
$request->request->add(['subTotal' => ($subTotal-($subTotal*$coupon_amount)/100)]);
// Rest of code goes here...
}
关于javascript - 如何保护我的表单输入字段数据不被用户更改到控制台?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58080896/