购买商品之后刷新页面又扣钱了SegmentFault
自己做的购买商品,购买成功跳转到(提示页面->ok),刷新提示页面,又重新扣钱了(又把代码走了一遍)。
我想实现当购买之后跳转到成功页面,如果用户手贱再刷新页面,就提示不能重复购买,必须回到商品列表选择购买
现在想不通该怎么做判断,求个思路
回复内容:
自己做的购买商品,购买成功跳转到(提示页面->ok),刷新提示页面,又重新扣钱了(又把代码走了一遍)。
我想实现当购买之后跳转到成功页面,如果用户手贱再刷新页面,就提示不能重复购买,必须回到商品列表选择购买
现在想不通该怎么做判断,求个思路
逻辑有问题,你确定你是跳转到纯粹的提示页面吗?订单处理之后输出ok和redirect(例如发送header进行url跳转)到ok是不同的,前者会出现你这个情况,后者不会,因为成功页面通常几乎是一个纯html,怎么刷都不会有任何问题的。
另外,如果使用了购物车的话,订单生成后会清空购物车,所以再次刷新由于购物车已空也不会产生重复扣款。
自己仔细想想就行了哈,很容易解决的。
跳转成功后记得die掉所有的程序,还有就是像1楼说的那样---程序有问题,好好检查.
购买完毕 立刻二次跳转,不要让用户停留在提交订单处理页面
通常购买这类程序都是用户提交购买信息,程序验证,逻辑处理(添加订单信息、扣款、发送短信/消息等),提示信息。这其中提交购买信息到验证程序,之后由验证程序调起逻辑处理方法,处理完成后跳转到提示页面,所以在开发过程中要注意将逻辑处理部分与其它部分(验证、提示)等分离开来,逻辑处理程序不能由验证以外的其它部分调起,你显然是在逻辑处理页面直接输入提示信息了而没有转到单独的信息提示页面,在刷新页面时又重新访问了逻辑处理程序造成的这种问题
你在url里带上订单ID,例如/order/1234578,然后打开页面时,先拿到url的订单ID,查一下这个订单是否支付,支付就提示已支付了,如果未支付,就提示顾客再次去支付

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

In this chapter, we are going to learn the following topics related to routing ?

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Validator can be created by adding the following two lines in the controller.

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c
