0

I am using forms to retrieve data using post method. Once I do that, and retrieve data from database, if I want to refresh the page, my browser will give me alert window telling me it will have to resend data again. How would I go about making that window not appear?

BloodDrunk
  • 95
  • 1
  • 8

2 Answers2

0

On your form, you need to change the method="POST" to method="GET".

Also, you should alter the way you get the requests to "$_GET" and not "$_POST". You will notice that the parameters are going to appear on the URL after submiting.

Note that this isn't recomended for forms, it's often used for search boxes.

William Lee
  • 111
  • 6
  • Thanks, this helped me. :) – BloodDrunk Feb 09 '16 at 15:19
  • Just quick question: is it then prone to SQL Injections? – BloodDrunk Feb 09 '16 at 15:25
  • It all depends on what you have on your PHP code, the form method itself won't protect you from SQL injections, it will only be more explicit to the final user, if someone is trying to SQL inject your code, he will be able to do this using the POST method aswell. – William Lee Feb 10 '16 at 16:09
0

It should be form action another page and completing inserting data and than redirect to form page

or after completing data send redirect with jsvascript code like

window.location.href = window.location.pathname;
Jakir Hossain
  • 2,457
  • 18
  • 23