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 7490473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T15:36:45+00:00 2026-05-29T15:36:45+00:00

This question is so basic that I’m almost embarrassed to ask it, but it’s

  • 0

This question is so basic that I’m almost embarrassed to ask it, but it’s got me stumped. I’ve written a short code snippet to explain it:

<form id="MyForm" method="post" enctype="multipart/form-data" >
    <input type="file" id="get_file" name="get_file" >
    <input type="submit" name="submitForm" value="Submit" >
</form>

<?php
    if (isset($_POST['submitForm'])) {
    echo "<script type='text/javascript'>alert('Selected')</script>";
} else {    
    echo "<script type='text/javascript'>alert('Not selected')</script>";
}
?>

When I load this page the first time, the alert says “Not selected”. Good. I submit the form and the alert says “Selected”. Also good. But when I refresh the page, it’s still “Selected”. I don’t understand why the “IF” statement allows this to happen. I want my form to submit data once and not do it again until my user does it, not every time the page refreshes.

This seems like the kind of question that noobs ask when they’re too lazy to use Google, but I’ve looked (there are even some threads on this site that sort of address this issue, but nobody has presented a solution). I’ve read up on HTML forms, but I still don’t get it.

Is this something everyone knows but me? Can somebody clue me in? Thanks.

EDIT: If anybody ever stumbles over this thread and needs a quick-and-dirty fix, here’s one I just stumbled on. Just press the select key again, easily done using jQuery. The form is resubmitted, but the form variables are all cleared. Not elegant, maybe, but it works perfectly.

  • 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-05-29T15:36:47+00:00Added an answer on May 29, 2026 at 3:36 pm

    When you reload the page, it is resubmitting the POST request, which means the submitForm=Submit is part of the request body.

    You should use the Post/Redirect/Get pattern to avoid this.

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

Sidebar

Related Questions

Apologies for this basic question, but I am noob stumped. The below code works
I realise that this is a very basic question, but it is one which
This is probably a pretty basic question, but just something that I wanted to
This is probably a basic html/css question... I have a simple one-button form that
guys I know this question is very basic but I've met in few publications
Forgive my ignorance in asking this basic question but I've become so used to
This is a really basic question but this is the first time I've used
I hope this question is not considered too basic for this forum, but we'll
I know this question is quite basic but since there is lot of confusion
This feels like a really basic question...that I cant find the answer for! Just

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.