PHP Question.. clearing variables...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • galleryseek
    Confirmed User
    • Mar 2002
    • 8234

    #1

    PHP Question.. clearing variables...

    say for example you're submitting a form to the page it is on (php_self).. and say you hit the refresh button after submitting that form... all those variables are re-submitted which causes for duplication... how do you avoid that so that you can clear those variables out?

    i thought unset($variable) would work, but it doesn't.

    the code looks like:

    if (isset($comment)) {
    $date = time();
    $sqlquery6 = "INSERT INTO bgcomments
    VALUES ('id','$_SESSION[username]','$uid','$comment','$date')";
    $resultse = mysql_query($sqlquery6);

    unset($comment);
    }
  • jwerd
    Confirmed User
    • Jun 2003
    • 1953

    #2
    if (isset($_POST['comment']))
    {
    $date = time();
    $r = mysql_query("INSERT INTO bgcomments VALUES ('id','$_SESSION[username]','$uid','$comment','$date')");
    unset($comment);
    }
    Last edited by jwerd; 02-22-2004, 11:12 PM.
    Yii Framework Guru - Seasoned PHP vet - Partner @ XXXCoupon.com

    Comment

    • jwerd
      Confirmed User
      • Jun 2003
      • 1953

      #3
      I don't quite understand what you're doing. What I would do, however, is work on the syntax a bit more.

      maybe even add
      if($_SERVER['REQUEST_METHOD'] hahahaha post) {
      // code inside
      }
      that tells the script to only parse if the type is POST, meaning from a form of some sort hope that helps

      CHEERS
      Last edited by jwerd; 02-22-2004, 11:15 PM.
      Yii Framework Guru - Seasoned PHP vet - Partner @ XXXCoupon.com

      Comment

      Working...