Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8694175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:43:26+00:00 2026-06-13T00:43:26+00:00

I have a form/page that seems to submit the form data when the page

  • 0

I have a form/page that seems to submit the form data when the page loads. If you click “add record” it loads the page and creates a new entry into the database without entering any information. If you complete the form it works as desired but creates and additional record. What would cause the form to submit “on load”? Also I use this same form for other areas of the site with no issue but the data is stored into a different table.

My Code

    <?

    if(isset($_POST['title'])) {
        if(isset($_POST['gallery_1'])) {
            $gallery_1 = $_POST['gallery_1'];
        }
        if(isset($_POST['gallery_2'])) {
            $gallery_2 = $_POST['gallery_2'];
        }
            if(isset($_POST['gallery_3'])) {
            $gallery_3 = $_POST['gallery_3'];
        }
            if(isset($_POST['gallery_4'])) {
            $gallery_4 = $_POST['gallery_4'];
        }
            if(isset($_POST['gallery_5'])) {
            $gallery_5 = $_POST['gallery_5'];
        }

            if(isset($_POST['download_1'])) {
            $download_1 = $_POST['download_1'];
        }

            if(isset($_POST['download_2'])) {
            $download_2 = $_POST['download_2'];
        }

            if(isset($_POST['download_3'])) {
            $download_3 = $_POST['download_3'];
        }

        $title = $_POST['title'];
        $title_gallery = $_POST['title_gallery'];
        $date = $_POST['date'];
        $introduction = $_POST['introduction'];
        $download_1_title = $_POST['download_1_title'];
        $download_2_title = $_POST['download_2_title'];
        $download_3_title = $_POST['download_3_title'];
        $dropbox_title = $_POST['dropbox_title'];
        $dropbox_info = $_POST['dropbox_info'];
        $dropbox_link = $_POST['dropbox_link'];
        $video_title = $_POST['video_title'];
        $video = $_POST['video'];


        $handle = new Upload($_FILES['gallery_1']);
            if ($handle->uploaded) {
                $handle->file_max_size = 4000000;
                $handle->image_resize = true;
                $handle->image_ratio = true;
                $handle->image_ratio_crop = true;
                $handle->image_y = 407;
                $handle->image_x = 460;
                $handle->allowed = array('image/pjpeg','image/jpeg', 'image/jpg');
                $handle->Process($dir_dest);
                if ($handle->processed) {
                    echo 'issue image 1 uploaded ' . round(filesize($handle->file_dst_pathname)/256)/4 . 'KB<br /><br />';
                    $gallery_1 = $dir_pics.'/' . $handle->file_dst_name ;
                } else {
                    echo '  the following error occurred while uploading image 1<br />';
                    echo '  Error: ' . $handle->error . '<br /><br />';
                }
                $handle-> Clean();
            }



            $handle2 = new Upload($_FILES['gallery_2']);
            if ($handle2->uploaded) {
                $handle2->file_max_size = 4000000;
                $handle2->image_resize = true;
                $handle2->image_ratio = true;
                $handle2->image_ratio_crop = true;
                $handle2->image_y = 307;
                $handle2->image_x = 460;
                $handle2->allowed = array('image/pjpeg','image/jpeg', 'image/jpg');
                $handle2->Process($dir_dest);
                if ($handle2->processed) {
                    echo 'issue image 2 uploaded ' . round(filesize($handle2->file_dst_pathname)/256)/4 . 'KB<br /><br />';
                    $gallery_2 = $dir_pics.'/' . $handle2->file_dst_name ;
                } else {
                    echo '  the following error occurred while uploading image 2<br />';
                    echo '  Error: ' . $handle2->error . '<br /><br />';
                }
                $handle2-> Clean();
            }

            $handle3 = new Upload($_FILES['gallery_3']);
            if ($handle3->uploaded) {
                $handle3->file_max_size = 4000000;
                $handle3->image_resize = true;
                $handle3->image_ratio = true;
                $handle3->image_ratio_crop = true;
                $handle3->image_y = 307;
                $handle3->image_x = 460;
                $handle3->allowed = array('image/pjpeg','image/jpeg', 'image/jpg');
                $handle3->Process($dir_dest);
                if ($handle3->processed) {
                    echo 'issue image 3 uploaded ' . round(filesize($handle3->file_dst_pathname)/256)/4 . 'KB<br /><br />';
                    $gallery_3 = $dir_pics.'/' . $handle3->file_dst_name ;
                } else {
                    echo '  the following error occurred while uploading image 3<br />';
                    echo '  Error: ' . $handle3->error . '<br /><br />';
                }
                $handle3-> Clean();
            }

            $handle4 = new Upload($_FILES['gallery_4']);
            if ($handle4->uploaded) {
                $handle4->file_max_size = 4000000;
                $handle4->image_resize = true;
                $handle4->image_ratio = true;
                $handle4->image_ratio_crop = true;
                $handle4->image_y = 307;
                $handle4->image_x = 460;
                $handle4->allowed = array('image/pjpeg','image/jpeg', 'image/jpg');
                $handle4->Process($dir_dest);
                if ($handle4->processed) {
                    echo 'main image for issue uploaded ' . round(filesize($handle4->file_dst_pathname)/256)/4 . 'KB<br /><br />';
                    $gallery_4 = $dir_pics.'/' . $handle4->file_dst_name ;
                } else {
                    echo '  the following error occurred while uploading the main image<br />';
                    echo '  Error: ' . $handle4->error . '<br /><br />';
                }
                $handle4-> Clean();
            }

            $handle5 = new Upload($_FILES['gallery_5']);
            if ($handle5->uploaded) {
                $handle5->file_max_size = 4000000;
                $handle5->image_resize = true;
                $handle5->image_ratio = true;
                $handle5->image_ratio_crop = true;
                $handle5->image_y = 307;
                $handle5->image_x = 460;
                $handle5->allowed = array('image/pjpeg','image/jpeg', 'image/jpg');
                $handle5->Process($dir_dest);
                if ($handle5->processed) {
                    echo 'map image for issue uploaded ' . round(filesize($handle5->file_dst_pathname)/256)/4 . 'KB<br /><br />';
                    $gallery_5 = $dir_pics.'/' . $handle5->file_dst_name ;
                } else {
                    echo '  the following error occurred while uploading the map image<br />';
                    echo '  Error: ' . $handle5->error . '<br /><br />';
                }
                $handle5-> Clean();
            }


            $handle6 = new Upload($_FILES['download_1']);
            if ($handle6->uploaded) {
                $handle6->file_max_size = 4000000;
                $handle6->allowed = array('application/*', 'image/*');
                $handle6->Process($dir_dest);
                if ($handle6->processed) {
                    echo 'download one uploaded' . round(filesize($handle6->file_dst_pathname)/256)/4 . 'KB<br /><br />';
                    $download_1 = $dir_pics.'/' . $handle6->file_dst_name ;
                } else {
                    echo '  the following error occurred while uploading download one<br />';
                    echo '  Error: ' . $handle6->error . '<br /><br />';
                }
                $handle6-> Clean();
            }

            $handle7 = new Upload($_FILES['download_2']);
            if ($handle7->uploaded) {
                $handle->file_max_size = 4000000;
                $handle->allowed = array('application/*', 'image/*');
                $handle7->Process($dir_dest);
                if ($handle7->processed) {
                    echo 'download two uploaded' . round(filesize($handle7->file_dst_pathname)/256)/4 . 'KB<br /><br />';
                    $download_2 = $dir_pics.'/' . $handle7->file_dst_name ;
                } else {
                    echo '  the following error occurred while uploading download two<br />';
                    echo '  Error: ' . $handle7->error . '<br /><br />';
                }
                $handle7-> Clean();
            }

            $handle8 = new Upload($_FILES['download_3']);
            if ($handle8->uploaded) {
                $handle->file_max_size = 4000000;
                $handle->allowed = array('application/*', 'image/*');
                $handle8->Process($dir_dest);
                if ($handle8->processed) {
                    echo 'download three uploaded' . round(filesize($handle8->file_dst_pathname)/256)/4 . 'KB<br /><br />';
                    $download_3 = $dir_pics.'/' . $handle8->file_dst_name ;
                } else {
                    echo '  the following error occurred while uploading download three<br />';
                    echo '  Error: ' . $handle8->error . '<br /><br />';
                }
                $handle8-> Clean();
            }


        }

        $query = mysql_query("INSERT INTO news  (
id ,
title ,
title_gallery ,
date ,
introduction ,
gallery_1 ,
gallery_2 ,
gallery_3 ,
gallery_4 ,
gallery_5 ,
download_1 ,
download_2 ,
download_3 ,
download_1_title ,
download_2_title ,
download_3_title ,
dropbox_title ,
dropbox_info ,
dropbox_link ,
video_title ,
video
) VALUES

(NULL,
'$title',
'$title_gallery',
'$date',
'$introduction',
'$gallery_1',
'$gallery_2',
'$gallery_3',
'$gallery_4',
'$gallery_5',
'$download_1',
'$download_2',
'$download_3',
'$download_1_title',
'$download_2_title',
'$download_3_title',
'$dropbox_title',
'$dropbox_info',
'$dropbox_link',
'$video_title',
'$video');");

if($query) {
            $message = $title . " has been added";
        }else{
            $message = "an error occurred while updating this entry";
        }


    ?>
    </p>

    <? if(isset($_POST['title'])) { ?>
            <div id="content_holder">
              <p style="text-align:center;padding-top:20px;">
              <strong><? echo $message; ?></strong><br/>
              <span class="error"><? if($error_message) { echo $error_message; } ?></span>
              Add another <a href="add.php">Record/Item</a></p>
            <!-- end content_holder -->
            </div>
       <? }else{ ?>

The form… and Closing brackets…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T00:43:28+00:00Added an answer on June 13, 2026 at 12:43 am

    Your INSERT query is outside your if(isset($_POST['title'])) statement. A row is inserted on every page load with empty values.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form in an HTM page that, after pressing the submit button,
I have a form on a non-SSL page that I want to submit as
I have a page that seems to work fine other than updating new text
I have a form on a page that a user can use to create
I have a form page in PHP that reads a DBF, and conditionally converts
I currently have a web form aspx page that calls RegisterClientScriptBlock. This sends down
On a page that I'm designing I have a form with one input of
I have a page that have fileupload control, on the submission of the form,
I have a PHP page that queries a DB to populate a form for
I have a page that has several ajax submission forms. Each form has a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.