form validation code

From: Date: Wed, 30 Jun 2010 13:07:56 +0000
Subject: form validation code
Groups: php.general 
Request: Send a blank email to php-general+get-306560@lists.php.net to get a copy of this message
Hello, I've been looking at this to long, and am not seeing the issue. When i had the below php code set to !empty instead of !isset as it is now I got the value of the name variable echoed back, yet on sql insert that field, along with all others are empty, though no error is generated, just a bogus record is inserted. When I changed to !isset I'm now getting the die statement echoed as if no value was passed from the form. This is not the case, I filled it out completely. Can anyone tell me where this code went wrong? Thanks. Dave. Html form: <h3>Fields marked with a * (star) are required.</h3> <form method="post" action=""> <div> <label for="txtname">Name*:</label> <input type="text" name="name" /> <br /> </div> <div> <input id="reset" name="reset" type="reset"/> </div> <div> <input id="submit" name="submit" type="submit"/> </div> </form> </div> php Code: // Check if fields are isset echo "Field Checs.<br />"; if (!isset($_POST['name'])) { echo "The value of Name is " . $_POST['name']. "<br />"; } else { die('ERROR: Missing value - Event Name'); }

« previous php.general (#306560) next »