防止页面刷新,该怎么处理
防止页面刷新
我现在遇到了一个问题
开发一个电商平台与第三方支付相联接,付款完以后跳转到:付款成功的页面。。然后数据库里面的值就会增加。现在问题是我要是不停的刷新这个付款成功的页面。。我的数据库里面的值一直会不停的增加。有没有简单想法可以实现下,有人说你可以在设计一张表,一个已经付款一个未付款,付款后在更新这个表,后面的数据库就不执行了。这样肯定不行。。工作量太大了。
我想到一个可以通过$_SERVER['HTTP_REFERER']判断他的来源,如果是本网站则不执行数据库语句,如果不是则执行。
可这样效果不是很好。
有人也说用COOKIE可以实现,请问这是怎么实现的?因为他是从第三方网站跳转过来的参数值我只能在付款成功的页面存储。然后再拿出来判断?岂不是前后值都一样?数据库照样会执行?
------解决思路----------------------付款成功页面你嵌入逻辑操作干啥?你可以将逻辑操作写到支付接口数据返回同步文件做操作就好了。
------解决思路----------------------
不知道你的框架是如何的。
如果有业务逻辑层的话,先执行付款的业务逻辑,执行完之后不要直接显示结果画面,而是执行一个显示用的业务逻辑。在那个逻辑里显示结果画面。这样刷新的时候就只会刷新显示用的业务逻辑。不会重复提交。
还有种比较保险的办法。在提交的页面中,生成一个唯一码,放在session中,同时也放在画面的隐藏控件中,在提交时,判断session中和隐藏控件中的唯一码是否一致,是的情况下执行提交操作,操作完成后删除session中的唯一码。这样刷新的时候因为session中已经被删除,比对不一致,就可以提示不要重复刷新页面了。

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

WindowsServerBackup is a function that comes with the WindowsServer operating system, designed to help users protect important data and system configurations, and provide complete backup and recovery solutions for small, medium and enterprise-level enterprises. Only users running Server2022 and higher can use this feature. In this article, we will explain how to install, uninstall or reset WindowsServerBackup. How to Reset Windows Server Backup If you are experiencing problems with your server backup, the backup is taking too long, or you are unable to access stored files, then you may consider resetting your Windows Server backup settings. To reset Windows

Understand the meaning of HTTP 301 status code: common application scenarios of web page redirection. With the rapid development of the Internet, people's requirements for web page interaction are becoming higher and higher. In the field of web design, web page redirection is a common and important technology, implemented through the HTTP 301 status code. This article will explore the meaning of HTTP 301 status code and common application scenarios in web page redirection. HTTP301 status code refers to permanent redirect (PermanentRedirect). When the server receives the client's

With the popularity of the Internet, we use browsers to surf the Internet have become a way of life. In the daily use of browsers, we often encounter situations where we need to enter account passwords, such as online shopping, social networking, emails, etc. This information needs to be recorded by the browser so that it does not need to be entered again the next time you visit. This is when cookies come in handy. What are cookies? Cookie refers to a small data file sent by the server to the user's browser and stored locally. It contains user behavior of some websites.

How to implement HTTP streaming in C++? Create an SSL stream socket using Boost.Asio and the asiohttps client library. Connect to the server and send an HTTP request. Receive HTTP response headers and print them. Receives the HTTP response body and prints it.

On the occasion of releasing the build 26040 version of Windows Server, Microsoft announced the official name of the product: Windows Server 2025. Also launched is the Windows11WindowsInsiderCanaryChannel version build26040. Some friends may still remember that many years ago someone successfully converted Windows NT from workstation mode to server mode, showing the commonalities between various versions of Microsoft operating systems. Although there are clear differences between Microsoft's current version of the server operating system and Windows 11, those who pay attention to the details may be curious: why Windows Server updated the brand,

HTTP Status Code 200: Explore the Meaning and Purpose of Successful Responses HTTP status codes are numeric codes used to indicate the status of a server's response. Among them, status code 200 indicates that the request has been successfully processed by the server. This article will explore the specific meaning and use of HTTP status code 200. First, let us understand the classification of HTTP status codes. Status codes are divided into five categories, namely 1xx, 2xx, 3xx, 4xx and 5xx. Among them, 2xx indicates a successful response. And 200 is the most common status code in 2xx

Solution: 1. Retry: You can wait for a period of time and try again, or refresh the page; 2. Check the server load: Check the server's CPU, memory and disk usage. If the capacity limit is exceeded, you can try to optimize the server configuration or increase the capacity. Server resources; 3. Check server maintenance and upgrades: You can only wait until the server returns to normal; 4. Check network connection: Make sure the network connection is stable, check whether the network device, firewall or proxy settings are correct; 5. Ensure cache or CDN configuration Correct; 6. Contact the server administrator, etc.

Common problems and solutions for cookie settings, specific code examples are required. With the development of the Internet, cookies, as one of the most common conventional technologies, have been widely used in websites and applications. Cookie, simply put, is a data file stored on the user's computer that can be used to store the user's information on the website, including login name, shopping cart contents, website preferences, etc. Cookies are an essential tool for developers, but at the same time, cookie settings are often encountered
