关于用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>

ThesecrettokeepingaPHP-poweredwebsiterunningsmoothlyunderheavyloadinvolvesseveralkeystrategies:1)ImplementopcodecachingwithOPcachetoreducescriptexecutiontime,2)UsedatabasequerycachingwithRedistolessendatabaseload,3)LeverageCDNslikeCloudflareforservin

You should care about DependencyInjection(DI) because it makes your code clearer and easier to maintain. 1) DI makes it more modular by decoupling classes, 2) improves the convenience of testing and code flexibility, 3) Use DI containers to manage complex dependencies, but pay attention to performance impact and circular dependencies, 4) The best practice is to rely on abstract interfaces to achieve loose coupling.

Yes,optimizingaPHPapplicationispossibleandessential.1)ImplementcachingusingAPCutoreducedatabaseload.2)Optimizedatabaseswithindexing,efficientqueries,andconnectionpooling.3)Enhancecodewithbuilt-infunctions,avoidingglobalvariables,andusingopcodecaching

ThekeystrategiestosignificantlyboostPHPapplicationperformanceare:1)UseopcodecachinglikeOPcachetoreduceexecutiontime,2)Optimizedatabaseinteractionswithpreparedstatementsandproperindexing,3)ConfigurewebserverslikeNginxwithPHP-FPMforbetterperformance,4)

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl


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

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.
