thenature4u Posted December 11, 2007 Share Posted December 11, 2007 when the user is refreshing the page the same data(data type is text) is again inserting into the database...how to avoid it..... Link to comment https://forums.phpfreaks.com/topic/81150-solved-avoid-dump/ Share on other sites More sharing options...
~n[EO]n~ Posted December 11, 2007 Share Posted December 11, 2007 First do not allow blank values. Second, after saving clear the form fields. Third, if you refresh, show him the message "Please fill something...." Link to comment https://forums.phpfreaks.com/topic/81150-solved-avoid-dump/#findComment-411780 Share on other sites More sharing options...
phpQuestioner Posted December 11, 2007 Share Posted December 11, 2007 you could unset the variables: <?php if (!isset($_POST['mySubmitButton'])) { unset($foo1, $foo2, $foo3); // add each variable you want to unset header("Location: ". $_SERVER['PHP_SELF'] .""); exit; } else if (isset($_POST['mySubmitButton'])) { // mysql update or insert here echo "Thank You Data Has Been Received\n"; } ?> <form action="<?php echo ". $_SERVER['PHP_SELF'] ."; ?>" method="post"> <!-- Add Input Fields Here --> <input type="submit" name="mySubmitButton" value="Send"> </form> Link to comment https://forums.phpfreaks.com/topic/81150-solved-avoid-dump/#findComment-411782 Share on other sites More sharing options...
tapos Posted December 11, 2007 Share Posted December 11, 2007 Try this <?php if (isset($_POST['mySubmitButton'])) { // mysql update or insert here header("Location: ". $_SERVER['PHP_SELF'] .""); exit; } ?> <form action="<?php echo ". $_SERVER['PHP_SELF'] ."; ?>" method="post"> <!-- Add Input Fields Here --> <input type="submit" name="mySubmitButton" value="Send"> </form> Hope this will work. Thanks -- Tapos Pal Link to comment https://forums.phpfreaks.com/topic/81150-solved-avoid-dump/#findComment-411803 Share on other sites More sharing options...
thenature4u Posted December 11, 2007 Author Share Posted December 11, 2007 form is there in one php file and mysql insertion is there in another php file.....how to use the above the code.... because same form and mysql insertion are there in the same file.....iam unable to understand.. thankyou in advance Link to comment https://forums.phpfreaks.com/topic/81150-solved-avoid-dump/#findComment-411826 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.