almightyegg Posted March 4, 2009 Share Posted March 4, 2009 I have a page that automatically refreshes every 5 seconds, and you can post things on this page. Clearly that $_POST information will be processed again and again... how would I go about deleting it? I tried this if(isset($_POST[message])){ $insert = mysql_query("INSERT INTO chat (`userid`, `message`) VALUES('{$mem['id']}', '{$_POST['message']}')") or die(mysql_error()); unset($_POST[message]); } Quote Link to comment https://forums.phpfreaks.com/topic/147996-destroying-a-post-value/ Share on other sites More sharing options...
wildteen88 Posted March 4, 2009 Share Posted March 4, 2009 What are you using to refresh the page? Quote Link to comment https://forums.phpfreaks.com/topic/147996-destroying-a-post-value/#findComment-776738 Share on other sites More sharing options...
almightyegg Posted March 4, 2009 Author Share Posted March 4, 2009 <script type="text/JavaScript"> function timedRefresh(timeoutPeriod) { setTimeout("location.reload(true);",timeoutPeriod); } </script> </head> <body bgcolor="black" onload="JavaScript:timedRefresh(5000);"> Quote Link to comment https://forums.phpfreaks.com/topic/147996-destroying-a-post-value/#findComment-776740 Share on other sites More sharing options...
wildteen88 Posted March 4, 2009 Share Posted March 4, 2009 Use window.location instead. window.reload will resend the POST data. Quote Link to comment https://forums.phpfreaks.com/topic/147996-destroying-a-post-value/#findComment-776745 Share on other sites More sharing options...
almightyegg Posted March 4, 2009 Author Share Posted March 4, 2009 <script type="text/JavaScript"> function timedRefresh(timeoutPeriod) { setTimeout("window.location(true);",timeoutPeriod); } </script> it doesn't change now... Quote Link to comment https://forums.phpfreaks.com/topic/147996-destroying-a-post-value/#findComment-776748 Share on other sites More sharing options...
wildteen88 Posted March 4, 2009 Share Posted March 4, 2009 You have to define the location. window.location="http://yoursite.com/path/to/script.php"; Quote Link to comment https://forums.phpfreaks.com/topic/147996-destroying-a-post-value/#findComment-776755 Share on other sites More sharing options...
almightyegg Posted March 4, 2009 Author Share Posted March 4, 2009 It's still not doing anything and has a little error exclaimation mark in the corner <script type="text/JavaScript"> function timedRefresh(timeoutPeriod) { setTimeout("window.location="http://www.lordoftheabyss.com/chat/index.php";",timeoutPeriod); } </script> Quote Link to comment https://forums.phpfreaks.com/topic/147996-destroying-a-post-value/#findComment-776758 Share on other sites More sharing options...
wildteen88 Posted March 4, 2009 Share Posted March 4, 2009 <script type="text/JavaScript"> function refresh() { window.location="http://www.lordoftheabyss.com/chat/index.php" } function timedRefresh(timeoutPeriod) { setTimeout("refresh()",timeoutPeriod); } </script> Quote Link to comment https://forums.phpfreaks.com/topic/147996-destroying-a-post-value/#findComment-776761 Share on other sites More sharing options...
almightyegg Posted March 4, 2009 Author Share Posted March 4, 2009 Awesome! Thanks, that worked Erm, I have a quick question, how would I go about making it not reload if the user is currently typing in a text box?? Or is that a bit more complicated?? Quote Link to comment https://forums.phpfreaks.com/topic/147996-destroying-a-post-value/#findComment-776764 Share on other sites More sharing options...
wildteen88 Posted March 4, 2009 Share Posted March 4, 2009 You could look into event listeners for this. Or alternatively you could convert your chat to use AJAX that way only the HTML tag that contains your chat refreshes rather than the whole page. Quote Link to comment https://forums.phpfreaks.com/topic/147996-destroying-a-post-value/#findComment-776768 Share on other sites More sharing options...
almightyegg Posted March 4, 2009 Author Share Posted March 4, 2009 I was originally going to use AJAX but I had no idea where to start :S tbh, I have no idea what I'm doing with this at all Quote Link to comment https://forums.phpfreaks.com/topic/147996-destroying-a-post-value/#findComment-776777 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.