Prevent the form Resubmission When Page Refreshed
Hello Friends Ajj Me Apko Btaunga Ki Ham Kis Prkar Form Data Ko Dobara Resubmit Hone Se Kese Rok Sakte Hai.Hota Ye Hai Ki Jab Ham Koi Application,Form Etc Bnate Hai Php And Mysql Ka Use Karke To Ham Jab Ek Bar Form Me Data Enter Karke Data Ko Submit Karte Hai To Wo Data Submit Ho Jata Hai.But Agar Uske Bad Ham Refresh Ke Button Ko Click Karke Refresh Karte Hai To Dobara Form Data Resubmit Ho Jata Hai .Jiski Wajah Se Hamari Website Me Kaffi Problem A Jati Hai Or Wo Ache Se Work Nhi Karte .
Me Ajj Ki Is Post Me Mai Apki Is Problem Ka Solution Dunga.
Example code-
Index.php
<html>
<head>
</head>
<body>
<form method=”post” action=””/>
<input type=”text> name=”name”>
<input type=”submit” name=”submit”/>
</form>
</body>
</html>
<?php
If(Isset(‘$_POST[‘submit’]{
//your code
}
?>
Jese Is Trah Se Apka Purra Code Ek He Page Par Hai To Apko Ye Problem Ati Hai Ki Data Dubara Submit Ho Jata Hai But Aap Is Formate Me Kbhi Be Apna Code Na Likhe Aap Niche Diye Gye Trike Se Apni Script Ki Coding Kare Tab Apko Ye Problem Nhi Ayegi.
App Do Aalg Allag File Bana Lijiye-
· Index.php-yanha aap apna html form banayege
<html>
<head>
</head>
<body>
<form method=”post” action=”action.php”/>
<input type=”text> name=”name”>
<input type=”submit” name=”submit”/>
</form>
</body>
</html>
· Ab aap ek action.php Name se File bana lijiye Php code ke liye(aap apni marji se kisi be name se file bana sakte hai)
action.php
<?php
If(Isset($_POST[‘submit’]{
//your code
header(“location:index.php”);
}
?>
Yanha ham action.php Me Janha Ham Script Ko Run Karwayege Wanha Uske Sath Header Function Ka Use Karke Form Ko Submission Ke Bad Index.Php (Means Form) Page Par Redirect Karwa Denge Jiski Madad Se User Form Submit Karne Ke Bad Dobara index.php Page Par Redirect Ho Jayege Or Form Data Dobara Resubmit Nhi Hoga(
Prevent page from Submit on Refresh in PHP)
Me Ummid Karta Hu Ki Apko Ye Bat Samjh A Gyi Hogi But Agar Fir Be Koi Problem A Rhe Hai To Aap Mujse Contact Kar Sakte Ho Me Apki Codding Me Se Is Problem Ko Remove Kar Dunga.
Agar Apko Post Achi Lagi To Ise Apne Dosto Ke Sath Jrrur Share Karna.
Thank You
Team Gajabwap Web In Hindi
Also read-
ConversionConversion EmoticonEmoticon