I have a working PHP/MySQL application used for data entry. The data
entry screen includes a "Save" button. The PHP code for this button
looks like this:
if (isset($_POST['cmdSave']))
{
if ($_POST[txtStateFileNum ber] == "")
{
include ("InsertRecord. inc"); // Insert new record
}
else
{
include ("UpdateRecord. inc"); // Update existing record
}
}
This works great. If the State File Number (primary ID) field is
blank, a new record is added and a new State File Number assigned,
otherwise the existing record is updated. However, if the user enters
some data and clicks "Save" to insert a new record and then clicks the
browser (IE) Refresh button, the insert logic is repeated and another
record is added to the database. Apparently, the cmdSave button
remains set and pressing Refresh executes the "InsertReco rd" logic
again. The "Post" version of State File Number also remains blank
even though it exists on the screen after "Save".
I have tried quite a number of fixes for this problem, none of which
have worked satisfactorily. What I would like to do is reset the
cmdSave button after the InsertRecord logic executes. Is that
possible?
Alternately, if I could sense that the Refresh button had been clicked
rather than cmdSave, I could also prevent re-execution.
Register_global s is off.
Any suggestions are greatly appreciated.
entry screen includes a "Save" button. The PHP code for this button
looks like this:
if (isset($_POST['cmdSave']))
{
if ($_POST[txtStateFileNum ber] == "")
{
include ("InsertRecord. inc"); // Insert new record
}
else
{
include ("UpdateRecord. inc"); // Update existing record
}
}
This works great. If the State File Number (primary ID) field is
blank, a new record is added and a new State File Number assigned,
otherwise the existing record is updated. However, if the user enters
some data and clicks "Save" to insert a new record and then clicks the
browser (IE) Refresh button, the insert logic is repeated and another
record is added to the database. Apparently, the cmdSave button
remains set and pressing Refresh executes the "InsertReco rd" logic
again. The "Post" version of State File Number also remains blank
even though it exists on the screen after "Save".
I have tried quite a number of fixes for this problem, none of which
have worked satisfactorily. What I would like to do is reset the
cmdSave button after the InsertRecord logic executes. Is that
possible?
Alternately, if I could sense that the Refresh button had been clicked
rather than cmdSave, I could also prevent re-execution.
Register_global s is off.
Any suggestions are greatly appreciated.
Comment