我想将卡的某些数据带到下一页。
但是,如果我想通过表单发送数据,则用户可以从控制台进行更改。

如果我隐藏了输入字段,那么仍然可以通过控制台进行更改。

<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...
}

09-28 05:34