Re: Refresh Error

From: Date: Fri, 12 Sep 2003 07:38:02 +0000
Subject: Re: Refresh Error
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-162386@lists.php.net to get a copy of this message
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


« previous php.general (#162386) next »