Jump to content

Recommended Posts

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

It still submits on refresh.

 

heres more code

<?
include('include/user_check.php');
include('include/db_con.php');
$id = $_SESSION['track_id'];
            $dest_email='user@user.net';
//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

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.