php - if page refresh again value added? -


i'm using following form in project. in form values added when submit. after submit if refresh page existing values inserted again. need after submit refresh page, existing values not added. please me.

`<form name="form" method="post" action="<?php $_server['php_self'];?>">  <table width="918" border="0">   <tr>     <td width="222" height="300">&nbsp;</td>     <td width="686">      <table width="331" border="0">       <tr>         <td height="30"> <?php error_reporting (e_all ^ e_notice); include("config.php"); $class_section=$_post['class_section'];  if(isset($_post['submit'])) { $sql=mysql_query("insert section(section_id, class_section) values ('', '$class_section')",$conn); if($sql) { echo"<p><center><b><font color='green'>section added successfully!</font></b></center></p>"; } else { echo"<p><center><b><font color='red'>section add failed!</font></b></center></p>"; } }  ?>         </td>         </tr>         </table>     <table width="331" border="0">             <tr>         <td height="47">class section/group</td>         <td><input name="class_section" type="text"/>       </td>       </tr>       <tr>         <td height="33"></td>          <td><input type="submit" name="submit" value="add" class="button">             </td>       </tr>     </table></td>   </tr> </table> </form>` 

use post/redirect/get pattern.

a user initiated request updates state on server should post.

your code has sql injection vulnerability.

wrap $class_section mysql_real_escape_string() before use it.


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -