matthewst Posted October 8, 2007 Share Posted October 8, 2007 I have a form that keeps submitting itself when I load the page or hit refresh. I don't know how to make it stop. if (isset($_POST["submit"])) { //if($_POST["submit"]){ //if($submit) { $ad_now=(mktime()-21600); $sql_daily = "INSERT INTO ad_total_daily (img, date_time) VALUES ('1', '$ad_now')"; $result_daily = mysql_query($sql_daily); <form action="<?=$PHP_SELF;?>" method="post" enctype="multipart/form-data" name="FormName"> <input type="submit" class="formTextbox" name="submit" value="Submit"> Link to comment https://forums.phpfreaks.com/topic/72347-form-submits-on-refresh/ Share on other sites More sharing options...
The Little Guy Posted October 8, 2007 Share Posted October 8, 2007 could we see more? otherwise, after the "Process" information is done, I would do this: <?php unset($_POST); ?> Link to comment https://forums.phpfreaks.com/topic/72347-form-submits-on-refresh/#findComment-364855 Share on other sites More sharing options...
darkfreaks Posted October 8, 2007 Share Posted October 8, 2007 kaching! solved? Link to comment https://forums.phpfreaks.com/topic/72347-form-submits-on-refresh/#findComment-364857 Share on other sites More sharing options...
matthewst Posted October 8, 2007 Author Share Posted October 8, 2007 It still submits on refresh. heres more code <? include('include/user_check.php'); include('include/db_con.php'); $id = $_SESSION['track_id']; $dest_email='[email protected]'; //if (isset($_POST["submit"])) { if($_POST["submit"]){ //if($submit) { //insert queries that don't submit on refresh //the following submits itself on load and refresh $ad_now=(mktime()-21600); $sql_daily = "INSERT INTO ad_total_daily (img, date_time) VALUES ('1', '$ad_now')"; $result_daily = mysql_query($sql_daily); $sql_weekly = "INSERT INTO ad_total_weekly (img, date_time) VALUES ('1', '$ad_now')"; $result_weekly = mysql_query($sql_weekly); $sql_monthly = "INSERT INTO ad_total_monthly (img, date_time) VALUES ('1', '$ad_now')"; $result_monthly = mysql_query($sql_monthly); $sql_yearly = "INSERT INTO ad_total_yearly (img, date_time) VALUES ('1', '$ad_now')"; $result_yearly = mysql_query($sql_yearly); $sql_ytd = "INSERT INTO ad_total_ytd (img, date_time) VALUES ('1', '$ad_now')"; $result_ytd = mysql_query($sql_ytd); //end self submit ?> <?php unset($_POST); ?> //all my form junk Link to comment https://forums.phpfreaks.com/topic/72347-form-submits-on-refresh/#findComment-364866 Share on other sites More sharing options...
Orio Posted October 8, 2007 Share Posted October 8, 2007 I cant see you closing the if()'s curly brace. Also, use $_POST['submit'] (with single quotes), I think it's a more correct way to code. Orio. Link to comment https://forums.phpfreaks.com/topic/72347-form-submits-on-refresh/#findComment-364868 Share on other sites More sharing options...
matthewst Posted October 8, 2007 Author Share Posted October 8, 2007 They're in the page just not in what I posted. The page does submit like it should when I hit the submit button, it then reloads itself without resubmitting. It just submits on first loading and refreshes. Link to comment https://forums.phpfreaks.com/topic/72347-form-submits-on-refresh/#findComment-364873 Share on other sites More sharing options...
matthewst Posted October 8, 2007 Author Share Posted October 8, 2007 fixed the submit on load problem now the only problem is it still submit on refresh funny thing is only does that in opera it works fine in firefox and ie Link to comment https://forums.phpfreaks.com/topic/72347-form-submits-on-refresh/#findComment-364879 Share on other sites More sharing options...
The Little Guy Posted October 8, 2007 Share Posted October 8, 2007 well then, I think you have an HTML problem. Link to comment https://forums.phpfreaks.com/topic/72347-form-submits-on-refresh/#findComment-364881 Share on other sites More sharing options...
matthewst Posted October 9, 2007 Author Share Posted October 9, 2007 thanks for the help so far I've tried unset($_POST); and unset($_POST['submit']); giving up on this for now Link to comment https://forums.phpfreaks.com/topic/72347-form-submits-on-refresh/#findComment-365634 Share on other sites More sharing options...
darkfreaks Posted October 9, 2007 Share Posted October 9, 2007 <?php $submit= $_POST['submit']; if (isset($submit)) { $sql="insert into foobar values(hoo,ha)"; echo 'congrats your data was inserted'; unset($submit);} ?> Link to comment https://forums.phpfreaks.com/topic/72347-form-submits-on-refresh/#findComment-365728 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.