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 Link to comment https://forums.phpfreaks.com/topic/118591-how-to-remove-form-field-value-in-php/ 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. Link to comment https://forums.phpfreaks.com/topic/118591-how-to-remove-form-field-value-in-php/#findComment-610520 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. Link to comment https://forums.phpfreaks.com/topic/118591-how-to-remove-form-field-value-in-php/#findComment-610522 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 Link to comment https://forums.phpfreaks.com/topic/118591-how-to-remove-form-field-value-in-php/#findComment-610558 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 Link to comment https://forums.phpfreaks.com/topic/118591-how-to-remove-form-field-value-in-php/#findComment-610564 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 } Link to comment https://forums.phpfreaks.com/topic/118591-how-to-remove-form-field-value-in-php/#findComment-610565 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. Link to comment https://forums.phpfreaks.com/topic/118591-how-to-remove-form-field-value-in-php/#findComment-610567 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 Link to comment https://forums.phpfreaks.com/topic/118591-how-to-remove-form-field-value-in-php/#findComment-610569 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. Link to comment https://forums.phpfreaks.com/topic/118591-how-to-remove-form-field-value-in-php/#findComment-610578 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. Link to comment https://forums.phpfreaks.com/topic/118591-how-to-remove-form-field-value-in-php/#findComment-610579 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. Link to comment https://forums.phpfreaks.com/topic/118591-how-to-remove-form-field-value-in-php/#findComment-610585 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 . Link to comment https://forums.phpfreaks.com/topic/118591-how-to-remove-form-field-value-in-php/#findComment-610593 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. Link to comment https://forums.phpfreaks.com/topic/118591-how-to-remove-form-field-value-in-php/#findComment-610611 Share on other sites More sharing options...
beboo002 Posted August 8, 2008 Author Share Posted August 8, 2008 Anyone Link to comment https://forums.phpfreaks.com/topic/118591-how-to-remove-form-field-value-in-php/#findComment-611410 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.