sonesay 7 Report post Posted April 1, 2008 (edited) The reason why its keeps reposting is because the post variable are saved since its posted to the same page. When you reload you reload the post lol. The only other way to do it so you can reload that page without double posting is to have it submit to a page thats designed specifically for inserting in to the database. Then redirect it back to the original page where you display form and last previous five message. I'm pretty sure that will work so you need an extra php page.I dont think its possible to destroy post variables after a post. I could be wrong but I dont think we have acess to anything like that.. doubt it lol. Edited April 1, 2008 by sonesay (see edit history) Share this post Link to post Share on other sites
jlhaslip 4 Report post Posted April 1, 2008 Does this work any better?I have adjusted it a little so that it checks to see if the Form is 'set' before assigning the variables used. <?ini_set("display_errors", 1);error_reporting(E_ALL);//the host, name, and password for your mysqlmysql_connect("localhost","not tellin you!","not tellin");//select the databasemysql_select_db("not tellin");if(isset($_POST['submit'])){ $submit = $_POST['submit']; $name = $_POST['name']; $message = $_POST['message']; //use the PHP date function for the time $time=date("h:ia d/j/y"); // inserting it into the shoutbox table which we made in the mysql statements before $result=MYSQL_QUERY("INSERT INTO shoutbox (id,name,message,time)". "VALUES ('NULL','$name', '$message','$time')");}?><?//returning the last 5 messages$result = mysql_query("select * from shoutbox order by id desc limit 5");//the while loopwhile($r=mysql_fetch_assoc($result)){//variables from tableecho $r["time"]."<br/>\n".$r["id"]."<br/>\n".$r["name"].":<br/>\n".$r["message"]."<br/>\n";}?><form action="" method="post"><INPUT TYPE='TEXT' value='name' NAME='name' SIZE=30 maxlength='100' /><br /><INPUT TYPE='TEXT' value='message' NAME='message' SIZE=30 maxlength='100' /><br /><input type="submit" name="submit" value="submit"></form> Share this post Link to post Share on other sites
KansukeKojima 0 Report post Posted April 1, 2008 Thanks jlhaslip, I tried what you posted unfortuneately, it does not work. But, I've found something that does, and unless someone can come up with a better method... <iframes>!Fortuneately, it keeps the shoutbox from re-posting... so I'll probably be using them... unfortuneately xD... If someone has a better idea...I'll use it. Share this post Link to post Share on other sites
sonesay 7 Report post Posted April 1, 2008 if you really need to do it on the same page and not like how I said previous post with submitting to another page then redirecting back to the original. that way save post variables are lost then..You can probably do it with some javascript. Set a flag for when the submit button is acutally pressed. That way you can distinguish between page reloads and real submissions. I wont give you exact code but that is the idea. Have a onclick function on your button to set flag that it is a real submit then check on your if statement code. If you really need the exact logic and code reply lol. Share this post Link to post Share on other sites
KansukeKojima 0 Report post Posted April 1, 2008 (edited) Err... yeah wait... I'll try out what you said in your previous post...*EDIT* Ok, I did what you suggested in the previous post. Works like a charm! Thank you so much!!feel free to test it outhttp://forums.xisto.com/no_longer_exists/ (click the 'Open Shoutbox Window' link)EDIT 2bbcode is now included. Edited April 2, 2008 by KansukeKojima (see edit history) Share this post Link to post Share on other sites