mrblack Posted February 28, 2006 Share Posted February 28, 2006 Hi,I am facing a vierd problem.I do a insert with the data from a form. It gets updated fine into the database. Then i go to some other page and come back to the first page and i find that there are multiple entries of the previous data and the number is not fixed, it chages each time.I have tried changing the auto increment and manually updating the serial number, still i see the same issue.Any suggestions would be appretiated.Thanks in advace.Ducane. Quote Link to comment https://forums.phpfreaks.com/topic/3757-inserts-multiple-rows-into-mysql/ Share on other sites More sharing options...
wickning1 Posted February 28, 2006 Share Posted February 28, 2006 Are you using your back button? Some browsers repost form data without warning you.Without seeing some code I'm afraid I can't be any more help than that. Quote Link to comment https://forums.phpfreaks.com/topic/3757-inserts-multiple-rows-into-mysql/#findComment-13038 Share on other sites More sharing options...
loki_racer Posted February 28, 2006 Share Posted February 28, 2006 An easy way to avoid this is force a redirect after the form information has been submitted to the database via:[code]header("Location: nextpage.php");[/code]This will make it so that when someone uses the back button to return to the form, it will be the blank version. Quote Link to comment https://forums.phpfreaks.com/topic/3757-inserts-multiple-rows-into-mysql/#findComment-13044 Share on other sites More sharing options...
mrblack Posted February 28, 2006 Author Share Posted February 28, 2006 [!--quoteo(post=350257:date=Feb 28 2006, 11:27 AM:name=wickning1)--][div class=\'quotetop\']QUOTE(wickning1 @ Feb 28 2006, 11:27 AM) [snapback]350257[/snapback][/div][div class=\'quotemain\'][!--quotec--]Are you using your back button? Some browsers repost form data without warning you.Without seeing some code I'm afraid I can't be any more help than that.[/quote]$db = mysql_connect("localhost", "root", "root");mysql_select_db("pts_extend", $db); if (isset( $_REQUEST[add])) { if(!($_REQUEST[add] == '')) { $addValue = $_REQUEST[add]; $infoTypeResult = mysql_query("select itemtype from info_type", $db); $maxValue = 0; while ($infoRow = mysql_fetch_array($infoTypeResult)) { if($infoRow[itemtype] > $maxValue) { $maxValue = $infoRow[itemtype]; } } $maxValue++; mysql_query("insert into info_type (itemtype,description) values ('$maxValue','$addValue')", $db); mysql_query("commit"); } }if 'add' is set in request parameters, it will insert a row.i know that if i do a refersh, that should add one more row. But i actually navigate to another page and by buttons and navigate back.the number of rows may or may not be added and if added they are in random numbers - so that's really unexplainable.I am not sure which one of apache, mySql or Php is doing that!header("Location: nextpage.php");good one.my primary concern is inserting random addition.This is how that looks, initially it did not show multiple entries!Id Description1 Deployment 2 BRD Ready 3 Tech Design 4 HLE 5 ewr ewr 6 wer t 7 ewr ewr 8 ewr ewr 9 ewr ewr 10 ewr ewr 11 ewr ewr 12 ewr ewr 13 ewr ewr 14 ewr ewr 15 ewr ewr Quote Link to comment https://forums.phpfreaks.com/topic/3757-inserts-multiple-rows-into-mysql/#findComment-13046 Share on other sites More sharing options...
wickning1 Posted February 28, 2006 Share Posted February 28, 2006 Is it possible someone else is on your site? Maybe you should log IPs that use the form and see. Quote Link to comment https://forums.phpfreaks.com/topic/3757-inserts-multiple-rows-into-mysql/#findComment-13054 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.