Re: How to destroy a $variable

From: Date: Wed, 08 Aug 2001 01:11:15 +0000
Subject: Re: How to destroy a $variable
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-61936@lists.php.net to get a copy of this message
Don't set them to empty at the bottom of the file. Do it right after the INSERT to the database, and put the FORM below that. An unfair restaurant-recommendation script: <?php $message = ''; # Horribly insecure code for illustrative purposes only: if (isset($name) && trim($name) && $name != "McDonalds"){ mysql_query("insert into restaurants(name) values('$name')") or die(mysql_error()); Blank out name for a new entry if they succeeded: if (!mysql_errno()){ $name = ''; } } elseif ($name == "McDonalds"){ $message .= "We don't allow McDonalds to be recommened.<BR>\n"; } else{ $name = ''; } ?> <FORM> <INPUT NAME=name VALUE='<?php echo $name;?>'> </FORM> -- WARNING richard@zend.com address is an endangered species -- Use ceo@l-i-e.com Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm Volunteer a little time: http://chatmusic.com/volunteer.htm ----- Original Message ----- From: Gerard Samuel <trini0@optonline.net> Newsgroups: php.general To: PHP <php-general@lists.php.net> Sent: Saturday, August 04, 2001 12:34 AM Subject: How to destroy a $variable > Ok I have a form with a $PHP_SELF target, and I enter parts of the form > when they enter information if something is wrong with their input. Now > what I would like to do is destroy all the variables when the form is > correct and posted, so that when the page comes back up again, I post a > thank you message, and the form is blank. Just a thought. > I tried setting strings to empty after data is submitted to the database > like so $Age = ""; etc.... at the bottom of the file. > > Bounce some ideas of me. Thanks >

« previous php.general (#61936) next »