[PHP-DB] Resubmit on page refresh.

2002-09-17 Thread Rich Hutchins

I have a page that maintains a very simple list of items. The page shows the
current items on the list and provides an input field for the user to add
new items to the list. Everything works great. The only problem I'm having
is that each time the user clicks the Refresh button on the browser, I get
that dialog box telling me The page cannot be refreshed without sending the
information. Then the last value is added to the database again and again
and again each time the user hits the Refresh button. In know that's a
browser feature that I can't control, but is there a way that after
submitting the information to the database using the form and associated SQL
statements, I can unset the variables. I've already tried unset($sql) and
unset($variable), but to no avail.

Here's the php code from the top of the page:
if (isset($_POST[newStatus]))
{
$thisStatus=addslashes($_POST[newStatus]);
$addStatusSQL=INSERT INTO status values(Null,'$thisStatus');

mysql_query($addStatusSQL)
or die(mysql_error());

unset($_POST[newStatus]);
unset($addStatusSQL);
}
.
.
.
Many wondrous things happen in here...
.
.
.
And here's the form code from the bottom of the page:

form action=bookStatAdmin.php method=post
table
trtdinput type=text 
name=newStatus/input/td/tr
trtdnbsp;/td/tr
trtdinput type=submit 
name=submit/input/td/tr
/table
/form

Any suggestions?

Thank in advance.

Rich


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DB] Resubmit on page refresh.

2002-09-17 Thread John Holmes

I really hope you just subscribed, because this question already been
asked today...and yesterday... You should search the archive before you
post.

Anyhow, the solution to your problem can be solved by using a
processing page that does the insert into the database and then
redirects to the main page that shows the list. The processing page
should not display anything at all, just do the insert and redirect.
Then the refresh will just refresh the page it was redirect to, and have
nothing to do with the processing. 

---John Holmes...

 -Original Message-
 From: Rich Hutchins [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, September 17, 2002 9:49 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] Resubmit on page refresh.
 
 I have a page that maintains a very simple list of items. The page
shows
 the
 current items on the list and provides an input field for the user
to
 add
 new items to the list. Everything works great. The only problem I'm
having
 is that each time the user clicks the Refresh button on the browser, I
get
 that dialog box telling me The page cannot be refreshed without
sending
 the
 information. Then the last value is added to the database again and
again
 and again each time the user hits the Refresh button. In know that's a
 browser feature that I can't control, but is there a way that after
 submitting the information to the database using the form and
associated
 SQL
 statements, I can unset the variables. I've already tried unset($sql)
and
 unset($variable), but to no avail.
 
 Here's the php code from the top of the page:
   if (isset($_POST[newStatus]))
   {
   $thisStatus=addslashes($_POST[newStatus]);
   $addStatusSQL=INSERT INTO status
values(Null,'$thisStatus');
 
   mysql_query($addStatusSQL)
   or die(mysql_error());
 
   unset($_POST[newStatus]);
   unset($addStatusSQL);
   }
 .
 .
 .
 Many wondrous things happen in here...
 .
 .
 .
 And here's the form code from the bottom of the page:
 
   form action=bookStatAdmin.php method=post
   table
   trtdinput type=text
 name=newStatus/input/td/tr
   trtdnbsp;/td/tr
   trtdinput type=submit
 name=submit/input/td/tr
   /table
   /form
 
 Any suggestions?
 
 Thank in advance.
 
 Rich
 
 
 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php