关于用POST方法提交,怎么防止刷新时重复提交数据的有关问题
关于用POST方法提交,如何防止刷新时重复提交数据的问题
if(isset($_POST["sel"]){
$a=$_POST["sel"];
unset($_POST["sel"];
echo "";
}
......
这是显示的代码的顺序结构
我在提交后.当接收到这个数据了之后就算是ok了.然后注销掉$_POST["sel"]这个量.同时用javascript再次跳转到本页面来(我想这样就不会存在$_POST["sel"]这个数据了)..但是当所有执行完了之后我再刷新..它还是提示我"需要使用已输入的信息,返回此页可能需要重复已进行的所有操作.是否要继续操作?"
我想在刷新的时候不要出现这个提示..也就是彻底把POST数据注销掉..请问怎么做?
我在百度的时候查到这么几个方法..一个说是中设置不保留缓存.好像是什么"no-cache"..但是没有用..
再一个是说用到Post Redirect Get(PRG)..看了原理但是不知道怎么用..好像是用到什么HTTP 303跳转..但不懂..还请高手指教~
------解决方案--------------------
在看 舌尖上的中国...好吧,稍等一下
- PHP code
<?php if(!empty($_POST['name'])){ //处理POST数据 echo 'aaaaa'; exit; } ?> <!--载入jquery库--> <script type="text/javascript" src="Js/jquery-1.7.2.min.js"></script> <input id="yes" type="submit" name="sel1" value="aaa"> <input id="no" type="submit" name="sel2" value="bbb"> <input type="button" name="b_submit" id="b_submit" onclick="j_post();"> <script type="text/javascript"> function j_post(){ var txt=$("#yes").val(); var txt2=$("#no").val(); $.post("b.php", { name:txt, time:txt2}, function(data){ alert("Data Loaded: " + data); }); } </script> <br><font color="#e78608">------解决方案--------------------</font><br> 1 表单提交后跳到另外一个页面<br> 2 像 @PhpNewnew 说的,使用AJAX提交<br> 使用AJAX POST的时候,要注意提交按钮的“锁定”。<br><br> 3 给表单赋上一个唯一的uniqid,提交表单的时候检查此值。<br><br> 4 或者使用验证码(实际上和方法3原理一样) <div class="clear"> </div>

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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

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



Many users will choose the Huawei brand when choosing smart watches. Among them, Huawei GT3pro and GT4 are very popular choices. Many users are curious about the difference between Huawei GT3pro and GT4. Let’s introduce the two to you. . What are the differences between Huawei GT3pro and GT4? 1. Appearance GT4: 46mm and 41mm, the material is glass mirror + stainless steel body + high-resolution fiber back shell. GT3pro: 46.6mm and 42.9mm, the material is sapphire glass + titanium body/ceramic body + ceramic back shell 2. Healthy GT4: Using the latest Huawei Truseen5.5+ algorithm, the results will be more accurate. GT3pro: Added ECG electrocardiogram and blood vessel and safety

Why Snipping Tool Not Working on Windows 11 Understanding the root cause of the problem can help find the right solution. Here are the top reasons why the Snipping Tool might not be working properly: Focus Assistant is On: This prevents the Snipping Tool from opening. Corrupted application: If the snipping tool crashes on launch, it might be corrupted. Outdated graphics drivers: Incompatible drivers may interfere with the snipping tool. Interference from other applications: Other running applications may conflict with the Snipping Tool. Certificate has expired: An error during the upgrade process may cause this issu simple solution. These are suitable for most users and do not require any special technical knowledge. 1. Update Windows and Microsoft Store apps

For PHP developers, using POST to jump to pages with parameters is a basic skill. POST is a method of sending data in HTTP. It can submit data to the server through HTTP requests. The jump page processes and jumps the page on the server side. In actual development, we often need to use POST with parameters to jump to pages to achieve certain functional purposes.

Python simulates the browser sending post requests importrequests format request.postrequest.post(url,data,json,kwargs)#post request format request.get(url,params,kwargs)#Compared with get request, sending post request parameters are divided into forms ( x-www-form-urlencoded) json (application/json) data parameter supports dictionary format and string format. The dictionary format uses the json.dumps() method to convert the data into a legal json format string. This method requires

PHP is a widely used server-side scripting language that can be used to create interactive and dynamic web applications. When developing PHP applications, we usually need to submit user input data to the server for processing through forms. However, sometimes we need to determine whether form data has been submitted in PHP. This article will introduce how to make such a determination.

1. Java calls post interface 1. Use URLConnection or HttpURLConnection that comes with java. There is no need to download other jar packages. Call URLConnection. If the interface response code is modified by the server, the return message cannot be received. It can only be received when the response code is correct. to return publicstaticStringsendPost(Stringurl,Stringparam){OutputStreamWriterout=null;BufferedReaderin=null;StringBuilderresult=newSt

实现如下:server{listen80;listen443ssl;server_namenirvana.test-a.gogen;ssl_certificate/etc/nginx/ssl/nirvana.test-a.gogen.crt;ssl_certificate_key/etc/nginx/ssl/nirvana.test-a.gogen.key;proxy_connect_timeout600;proxy_read_timeout600;proxy_send_timeout600;c

PHP is a programming language widely used in website development, and page jumps and carrying POST data are common requirements in website development. This article will introduce how to implement PHP page jump and carry POST data, including specific code examples. In PHP, page jumps are generally implemented through the header function. If you need to carry POST data during the jump process, you can do it through the following steps: First, create a page containing a form, where the user fills in the information and clicks the submit button. Acti in the form
