Bluehost.com Web Hosting $6.95

Refresh Error

This is a discussion on Refresh Error within the PHP General forums, part of the PHP Programming Forums category; Okay, I'm displaying an entire table of numbers from my database. Using a form on the same page, you ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 09-11-2003
Rex Brooks
 
Posts: n/a
Default Refresh Error

Okay, I'm displaying an entire table of numbers from my database. Using a
form on the same page, you can enter an amount to add to the table and then
click submit. I pass all of the information in $_POST back to the same
page. Here is my code:


if ($_POST["number"] != NULL) {

if (is_numeric($_POST["number"]) || $_POST["number"] <= 0.0){
...
display stuff telling them they need to try again
...
}
else {
...
do stuff that adds the number to the table
...

$_POST["number"] = NULL;
}
}

...body of HTML document...

<form method="POST" action="table.php">
<table border="0" cellpadding="5">
<tr>
<td align="right">Add Amount</td>
<td><input type="text" name="number"></td>
</tr>
<tr>
<td colspan=2><center><input type="submit" value="Click to
Submit"></center></td>
</tr>
</table>
</form>

Everything seems to work fine, up until you click the refresh button, then
it will add whatever you just added to the table again, even if you have
nothing typed into the form and dont hit the submit button. So basically I
can add 500 by typing it in and clicking the submit button, then continue to
add an addition 500 every time I click the submit button. I want to be able
to refresh the page, but I cant figure out what is going wrong. Any ideas?

Rex
Reply With Quote
  #2 (permalink)  
Old 09-12-2003
Marek Kilimajer
 
Posts: n/a
Default Re: [PHP] Refresh Error

Does your explorer ask you if you want to resend the information? It
does. You post your form once again. If you don't want this to happen,
use header("Location: http://yourserver/your_form_page.php"); redirect.

Rex Brooks wrote:

> Okay, I'm displaying an entire table of numbers from my database. Using a
> form on the same page, you can enter an amount to add to the table and then
> click submit. I pass all of the information in $_POST back to the same
> page. Here is my code:
>
>
> if ($_POST["number"] != NULL) {
>
> if (is_numeric($_POST["number"]) || $_POST["number"] <= 0.0){
> ...
> display stuff telling them they need to try again
> ...
> }
> else {
> ...
> do stuff that adds the number to the table
> ...
>
> $_POST["number"] = NULL;
> }
> }
>
> ...body of HTML document...
>
> <form method="POST" action="table.php">
> <table border="0" cellpadding="5">
> <tr>
> <td align="right">Add Amount</td>
> <td><input type="text" name="number"></td>
> </tr>
> <tr>
> <td colspan=2><center><input type="submit" value="Click to
> Submit"></center></td>
> </tr>
> </table>
> </form>
>
> Everything seems to work fine, up until you click the refresh button, then
> it will add whatever you just added to the table again, even if you have
> nothing typed into the form and dont hit the submit button. So basically I
> can add 500 by typing it in and clicking the submit button, then continue to
> add an addition 500 every time I click the submit button. I want to be able
> to refresh the page, but I cant figure out what is going wrong. Any ideas?
>
> Rex
>

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 02:23 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0