beboo002 Posted August 7, 2008 Share Posted August 7, 2008 Hello Freaks, My question is how to remove form field value after inserting the database. Take an example that you have submit the form and form value store in the database . Form action is same. Here I am not using header (location:xyz.php). If you refresh the page then duplicate value store in database. How can I prevent the duplicate value in database while refresh the page? Thanks & Regard Beboo Quote Link to comment Share on other sites More sharing options...
deadlyp99 Posted August 7, 2008 Share Posted August 7, 2008 Just use a simple session. Set a sessions when the form is first submitted. When the php finds a post, before inserting data it will check for a session. If one exists it will not insert. Quote Link to comment Share on other sites More sharing options...
ratcateme Posted August 7, 2008 Share Posted August 7, 2008 you could give all your forms a number then when a users fills out a form store the form number in $_SESSION then when a users presses submit check $_SESSION to see if the user has already filled out that form. Scott. Quote Link to comment Share on other sites More sharing options...
beboo002 Posted August 7, 2008 Author Share Posted August 7, 2008 Thanks for reply Ok I think both solution is right but in First reply we need one more column in database if I use mail() then how can I do it. In Second reply if user fills same form in second time how can I insert the data. My question is how to prevent the duplicate value in database or mail() to refresh the browser Thanks Quote Link to comment Share on other sites More sharing options...
beboo002 Posted August 7, 2008 Author Share Posted August 7, 2008 In my domain I use 50 forms then I need to create 50 session to check Quote Link to comment Share on other sites More sharing options...
Xurion Posted August 7, 2008 Share Posted August 7, 2008 Something like this: session_start(); if($_SESSION['checkvar']==1){ //do the insert & mail functions here $_SESSION['checkvar']=1; }else{ //user already submitted form } Quote Link to comment Share on other sites More sharing options...
abdfahim Posted August 7, 2008 Share Posted August 7, 2008 why dont use REPLACE command insted of INSERT command in your mysql query? then duplicate values will be replaced automatically. Quote Link to comment Share on other sites More sharing options...
beboo002 Posted August 7, 2008 Author Share Posted August 7, 2008 ok i use replace command in mysql but in mail() what can i use. what is the value of $_SESSION['checkvar'] in first time it is $_SESSION['checkvar']==1. how can i insert in the if condition. Thanks Quote Link to comment Share on other sites More sharing options...
abdfahim Posted August 7, 2008 Share Posted August 7, 2008 I dont know why you dont want to use header but I guess using header is an easier solution then those sessions. Quote Link to comment Share on other sites More sharing options...
beboo002 Posted August 7, 2008 Author Share Posted August 7, 2008 yes i know but when we gave message then message will be store in session or cookies or make new page thanksurl. I dont want to that things for only message. Quote Link to comment Share on other sites More sharing options...
Xurion Posted August 7, 2008 Share Posted August 7, 2008 what is the value of $_SESSION['checkvar'] in first time it is $_SESSION['checkvar']==1. how can i insert in the if condition. By default, the $_SESSION['checkvar'] variable will be null as it is not set until it does the insert and mail functionality. Quote Link to comment Share on other sites More sharing options...
beboo002 Posted August 7, 2008 Author Share Posted August 7, 2008 Yes default session value is null but when once session is set then no one can entry same browser and same form again . Quote Link to comment Share on other sites More sharing options...
Xurion Posted August 7, 2008 Share Posted August 7, 2008 Only one user will be restricted, not everyone. Quote Link to comment Share on other sites More sharing options...
beboo002 Posted August 8, 2008 Author Share Posted August 8, 2008 Anyone Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.